Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
ad4e7ef3a4
9 changed files with 231 additions and 47 deletions
105
Assets/Prefabs/Door.prefab
Normal file
105
Assets/Prefabs/Door.prefab
Normal file
|
@ -0,0 +1,105 @@
|
||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!1001 &100100000
|
||||||
|
Prefab:
|
||||||
|
m_ObjectHideFlags: 1
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Modification:
|
||||||
|
m_TransformParent: {fileID: 0}
|
||||||
|
m_Modifications: []
|
||||||
|
m_RemovedComponents: []
|
||||||
|
m_ParentPrefab: {fileID: 0}
|
||||||
|
m_RootGameObject: {fileID: 1046373619020340}
|
||||||
|
m_IsPrefabParent: 1
|
||||||
|
--- !u!1 &1046373619020340
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_PrefabParentObject: {fileID: 0}
|
||||||
|
m_PrefabInternal: {fileID: 100100000}
|
||||||
|
serializedVersion: 5
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 4708397045567336}
|
||||||
|
- component: {fileID: 114712631247209960}
|
||||||
|
- component: {fileID: 61859685447846418}
|
||||||
|
- component: {fileID: 61191558022818200}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: UpperDoor
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &4708397045567336
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 1
|
||||||
|
m_PrefabParentObject: {fileID: 0}
|
||||||
|
m_PrefabInternal: {fileID: 100100000}
|
||||||
|
m_GameObject: {fileID: 1046373619020340}
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 9.06, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_RootOrder: 0
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!61 &61191558022818200
|
||||||
|
BoxCollider2D:
|
||||||
|
m_ObjectHideFlags: 1
|
||||||
|
m_PrefabParentObject: {fileID: 0}
|
||||||
|
m_PrefabInternal: {fileID: 100100000}
|
||||||
|
m_GameObject: {fileID: 1046373619020340}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_Density: 1
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_IsTrigger: 1
|
||||||
|
m_UsedByEffector: 0
|
||||||
|
m_UsedByComposite: 0
|
||||||
|
m_Offset: {x: -0.3731112, y: 0}
|
||||||
|
m_SpriteTilingProperty:
|
||||||
|
border: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
pivot: {x: 0, y: 0}
|
||||||
|
oldSize: {x: 0, y: 0}
|
||||||
|
newSize: {x: 0, y: 0}
|
||||||
|
adaptiveTilingThreshold: 0
|
||||||
|
drawMode: 0
|
||||||
|
adaptiveTiling: 0
|
||||||
|
m_AutoTiling: 0
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Size: {x: 3.025469, y: 1}
|
||||||
|
m_EdgeRadius: 0
|
||||||
|
--- !u!61 &61859685447846418
|
||||||
|
BoxCollider2D:
|
||||||
|
m_ObjectHideFlags: 1
|
||||||
|
m_PrefabParentObject: {fileID: 0}
|
||||||
|
m_PrefabInternal: {fileID: 100100000}
|
||||||
|
m_GameObject: {fileID: 1046373619020340}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_Density: 1
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_IsTrigger: 0
|
||||||
|
m_UsedByEffector: 0
|
||||||
|
m_UsedByComposite: 0
|
||||||
|
m_Offset: {x: -0.37311125, y: 0}
|
||||||
|
m_SpriteTilingProperty:
|
||||||
|
border: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
pivot: {x: 0, y: 0}
|
||||||
|
oldSize: {x: 0, y: 0}
|
||||||
|
newSize: {x: 0, y: 0}
|
||||||
|
adaptiveTilingThreshold: 0
|
||||||
|
drawMode: 0
|
||||||
|
adaptiveTiling: 0
|
||||||
|
m_AutoTiling: 0
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Size: {x: 3.0254688, y: 1}
|
||||||
|
m_EdgeRadius: 0
|
||||||
|
--- !u!114 &114712631247209960
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 1
|
||||||
|
m_PrefabParentObject: {fileID: 0}
|
||||||
|
m_PrefabInternal: {fileID: 100100000}
|
||||||
|
m_GameObject: {fileID: 1046373619020340}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 8b8cc30ac6e59724bba6536a17fbf027, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
8
Assets/Prefabs/Door.prefab.meta
Normal file
8
Assets/Prefabs/Door.prefab.meta
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 88e4526bbc633401ebdaaffa8a16c3aa
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 100100000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -169,6 +169,31 @@ Prefab:
|
||||||
propertyPath: m_LocalPosition.x
|
propertyPath: m_LocalPosition.x
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 114874769993434856, guid: 3d1911457c1e44f53b6b4044334db52f,
|
||||||
|
type: 2}
|
||||||
|
propertyPath: curveSpeed
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 114874769993434856, guid: 3d1911457c1e44f53b6b4044334db52f,
|
||||||
|
type: 2}
|
||||||
|
propertyPath: turnSpeed
|
||||||
|
value: 3
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 114874769993434856, guid: 3d1911457c1e44f53b6b4044334db52f,
|
||||||
|
type: 2}
|
||||||
|
propertyPath: drift
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 114874769993434856, guid: 3d1911457c1e44f53b6b4044334db52f,
|
||||||
|
type: 2}
|
||||||
|
propertyPath: friction
|
||||||
|
value: 0.5
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 114874769993434856, guid: 3d1911457c1e44f53b6b4044334db52f,
|
||||||
|
type: 2}
|
||||||
|
propertyPath: acceleration
|
||||||
|
value: 5
|
||||||
|
objectReference: {fileID: 0}
|
||||||
m_RemovedComponents: []
|
m_RemovedComponents: []
|
||||||
m_ParentPrefab: {fileID: 100100000, guid: 3d1911457c1e44f53b6b4044334db52f, type: 2}
|
m_ParentPrefab: {fileID: 100100000, guid: 3d1911457c1e44f53b6b4044334db52f, type: 2}
|
||||||
m_IsPrefabParent: 0
|
m_IsPrefabParent: 0
|
||||||
|
|
|
@ -4,5 +4,5 @@ using UnityEngine;
|
||||||
|
|
||||||
public class Collectable : Entity{
|
public class Collectable : Entity{
|
||||||
|
|
||||||
public Collectable (EntityObjective referringObjective, GameObject entityPrefab) : base(referringObjective, entityPrefab) {}
|
public Collectable (EntityObjective referringObjective) : base(referringObjective) {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,31 +2,19 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public abstract class Entity {
|
public abstract class Entity : MonoBehaviour{
|
||||||
EntityObjective referringObjective;
|
EntityObjective referringObjective;
|
||||||
GameObject entityPrefab;
|
|
||||||
GameObject instance;
|
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
public Entity(EntityObjective referringObjective, GameObject entityPrefab)
|
public Entity(EntityObjective referringObjective)
|
||||||
{
|
{
|
||||||
this.referringObjective = referringObjective;
|
this.referringObjective = referringObjective;
|
||||||
this.entityPrefab = entityPrefab;
|
|
||||||
}
|
|
||||||
|
|
||||||
// spawns the entity
|
|
||||||
public void Spawn(Transform spawnPoint)
|
|
||||||
{
|
|
||||||
// instance = GameObject.Instantiate (entityPrefab);
|
|
||||||
// instance.transform = spawnPoint;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// kills the entity
|
// kills the entity
|
||||||
public void Kill()
|
public void Kill()
|
||||||
{
|
{
|
||||||
GameObject.Destroy (instance);
|
if(referringObjective != null)
|
||||||
referringObjective.Remove (this);
|
referringObjective.Remove (this.gameObject);
|
||||||
|
|
||||||
instance = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
36
Assets/Scripts/Entities/Mob.cs
Normal file
36
Assets/Scripts/Entities/Mob.cs
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public abstract class Mob : Entity {
|
||||||
|
readonly int maxHP;
|
||||||
|
int currentHP;
|
||||||
|
bool isDead;
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
public Mob(EntityObjective referringObjective, int maxHP) : base(referringObjective)
|
||||||
|
{
|
||||||
|
this.maxHP = maxHP;
|
||||||
|
currentHP = maxHP;
|
||||||
|
|
||||||
|
isDead = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// inflicts damage to this mob
|
||||||
|
public void InflictDamage(int damage)
|
||||||
|
{
|
||||||
|
currentHP -= damage;
|
||||||
|
if (!isDead && currentHP <= 0)
|
||||||
|
{
|
||||||
|
base.Kill ();
|
||||||
|
isDead = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Heals the mob
|
||||||
|
public void Heal(int healAmount)
|
||||||
|
{
|
||||||
|
if (!isDead)
|
||||||
|
currentHP = (currentHP + healAmount > currentHP) ? maxHP : currentHP + healAmount;
|
||||||
|
}
|
||||||
|
}
|
11
Assets/Scripts/Entities/Mob.cs.meta
Normal file
11
Assets/Scripts/Entities/Mob.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7c34c451bf3a8c24f823ca94395753ab
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -3,14 +3,14 @@ using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class EntityObjective : Objective{
|
public class EntityObjective : Objective{
|
||||||
List<Entity> entityList;
|
List<GameObject> prefabList;
|
||||||
|
List<GameObject> entityList;
|
||||||
List<Transform> spawnPointList;
|
List<Transform> spawnPointList;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
public EntityObjective(Room objectiveCaller, List<Entity> entityList) : base(objectiveCaller)
|
public EntityObjective(Room objectiveCaller, List<GameObject> prefabList) : base(objectiveCaller)
|
||||||
{
|
{
|
||||||
this.entityList = entityList;
|
this.prefabList = prefabList;
|
||||||
this.spawnPointList = spawnPointList;
|
|
||||||
spawnPointList = objectiveCaller.GetSpawnpoints ();
|
spawnPointList = objectiveCaller.GetSpawnpoints ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,14 +19,17 @@ public class EntityObjective : Objective{
|
||||||
{
|
{
|
||||||
Random newRand = new Random ();
|
Random newRand = new Random ();
|
||||||
|
|
||||||
foreach (Entity i in entityList)
|
foreach (GameObject i in prefabList)
|
||||||
i.Spawn(spawnPointList[Random.Range(0, spawnPointList.Count)]);
|
{
|
||||||
|
GameObject tempObject = GameObject.Instantiate (i);
|
||||||
|
tempObject.transform.position = spawnPointList [Random.Range (0, spawnPointList.Count)].position;
|
||||||
|
}
|
||||||
|
|
||||||
objectiveCaller.Lock();
|
objectiveCaller.Lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Removes the entity from the list and completes the objective, if the list is empty
|
// Removes the entity from the list and completes the objective, if the list is empty
|
||||||
public void Remove(Entity inputEntity)
|
public void Remove(GameObject inputEntity)
|
||||||
{
|
{
|
||||||
entityList.Remove (inputEntity);
|
entityList.Remove (inputEntity);
|
||||||
if (entityList.Count == 0)
|
if (entityList.Count == 0)
|
||||||
|
|
|
@ -2,42 +2,50 @@
|
||||||
|
|
||||||
public class PlayerMovement : MonoBehaviour {
|
public class PlayerMovement : MonoBehaviour {
|
||||||
|
|
||||||
public float power = 3;
|
[SerializeField]
|
||||||
public float turnpower = 2;
|
public float acceleration = 3;
|
||||||
public float curveSpeed = 0.5f;
|
[SerializeField]
|
||||||
Vector3 curspeed;
|
public float friction = 0.1f;
|
||||||
|
[SerializeField]
|
||||||
|
public float turnSpeed = 2;
|
||||||
|
[SerializeField]
|
||||||
|
public float drift = 1f;
|
||||||
|
|
||||||
Rigidbody2D rigidbody2D;
|
Rigidbody2D rigidbody2D;
|
||||||
|
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
void Start()
|
void Start() {
|
||||||
{
|
|
||||||
rigidbody2D = GetComponent<Rigidbody2D>();
|
rigidbody2D = GetComponent<Rigidbody2D>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FixedUpdate() {
|
void FixedUpdate() {
|
||||||
|
Vector3 speedVec = new Vector3(rigidbody2D.velocity.x, rigidbody2D.velocity.y, 0);
|
||||||
curspeed = new Vector3(rigidbody2D.velocity.x, rigidbody2D.velocity.y, 0);
|
float speed = speedVec.magnitude;
|
||||||
|
|
||||||
//curspeed = curspeed.normalized;
|
|
||||||
//curspeed *= maxspeed;
|
|
||||||
|
|
||||||
rigidbody2D.AddForce(transform.up * power);
|
|
||||||
Vector3 forwardNorm = (transform.localRotation * Vector3.up).normalized * curspeed.magnitude;
|
|
||||||
Vector3 br = forwardNorm - curspeed;
|
|
||||||
br *= curveSpeed;
|
|
||||||
rigidbody2D.AddForce(br);
|
|
||||||
//Debug.Log(br);
|
|
||||||
|
|
||||||
|
{ // Forward
|
||||||
|
rigidbody2D.AddForce(transform.up * acceleration);
|
||||||
|
}
|
||||||
|
{// Drag
|
||||||
|
Vector3 drag = speedVec.normalized * speed * speed * friction * -1;
|
||||||
|
rigidbody2D.AddForce(drag);
|
||||||
|
Debug.DrawLine(transform.position, transform.position + drag, Color.cyan, 0.01f, false);
|
||||||
|
}
|
||||||
|
{ // Drift
|
||||||
|
Vector3 forwardNorm = (transform.localRotation * Vector3.up).normalized * speedVec.magnitude;
|
||||||
|
Vector3 br = forwardNorm - speedVec;
|
||||||
|
br *= drift;
|
||||||
|
rigidbody2D.AddForce(br);
|
||||||
|
//Debug.Log(br);
|
||||||
|
Debug.DrawLine(transform.position, transform.position + br, Color.red, 0.01f, false);
|
||||||
|
}
|
||||||
if (Input.GetKey(KeyCode.A)){
|
if (Input.GetKey(KeyCode.A)){
|
||||||
transform.Rotate(Vector3.forward * turnpower);
|
transform.Rotate(Vector3.forward * turnSpeed);
|
||||||
}
|
}
|
||||||
if (Input.GetKey(KeyCode.D)) {
|
if (Input.GetKey(KeyCode.D)) {
|
||||||
transform.Rotate(Vector3.forward * -turnpower);
|
transform.Rotate(Vector3.forward * -turnSpeed);
|
||||||
}
|
}
|
||||||
// Debug lines
|
// Debug lines
|
||||||
Debug.DrawLine(transform.position, transform.position + curspeed, Color.magenta, 0.01f, false);
|
Debug.DrawLine(transform.position, transform.position + speedVec, Color.magenta, 0.01f, false);
|
||||||
Debug.DrawLine(transform.position, transform.position + br, Color.red, 0.01f, false);
|
|
||||||
Debug.DrawLine(transform.position, transform.position + transform.localRotation * Vector3.up, Color.yellow, 0.01f, false);
|
Debug.DrawLine(transform.position, transform.position + transform.localRotation * Vector3.up, Color.yellow, 0.01f, false);
|
||||||
|
|
||||||
//Debug.Log(transform.localRotation.eulerAngles);
|
//Debug.Log(transform.localRotation.eulerAngles);
|
||||||
|
|
Loading…
Add table
Reference in a new issue