//public Animation[] Animations; private void Awake() { Creature_Stats = GetComponent <CreatureStats>(); Creature_Movement = GetComponent <CreatureMovement>(); Hived = false; C_animator = GetComponentsInChildren <Animator>(); }
private void OnCreatureSelect(GameObject o) { Show(); _dna = o.GetComponent <Dna>(); _fov = o.GetComponent <CreatureFieldOfView>(); _movement = o.GetComponent <CreatureMovement>(); }
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { base.OnStateEnter(animator, stateInfo, layerIndex); _movement = gameObject.GetComponent <CreatureMovement>(); _movement.isRunning = false; _coroutine = _movement.StartCoroutine(GetRandomTarget(roamInterval)); }
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { base.OnStateEnter(animator, stateInfo, layerIndex); _movement = gameObject.GetComponent <CreatureMovement>(); _movement.isRunning = true; _movement.target = gameObject.transform.parent.position; }
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { base.OnStateEnter(animator, stateInfo, layerIndex); _movement = gameObject.GetComponent <CreatureMovement>(); _fov = gameObject.GetComponent <CreatureFieldOfView>(); _movement.isRunning = false; _movement.target = GetFoodPos(); }
private void Start() { gameController = FindObjectOfType <GameController>(); creatureMovement = GetComponent <CreatureMovement>(); gameController.startDay += StartDay; gameController.stopDay += StopDay; initialStats = creatureStats; ApplyStats(); }
void Start() { targetAchieved = false; movement = this.gameObject.GetComponent <CreatureMovement>(); eat = this.gameObject.GetComponent <CreatureConsumption>(); see = this.gameObject.GetComponent <CreatureDetection>(); sex = this.gameObject.GetComponent <CreatureReproduction>(); myPos = this.gameObject.transform.position; StartCoroutine(cycle()); }
void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.layer == 0 || other.gameObject.layer == 9) { onJumping = false; } if (other.gameObject.layer == 9) { BlockStatus block = other.gameObject.GetComponent <BlockStatus>(); switch (block.type) { case "Jumper": Vector2 jumperVelocity = new Vector2(0, block.value); rigid.AddForce(jumperVelocity, ForceMode2D.Impulse); break; case "DJumper": jumpCount = 0; doubleJump = true; break; case "PortalEnter": Vector3 anotherPortalPos = block.portal.transform.position; Vector3 warpPos = new Vector3(anotherPortalPos.x, anotherPortalPos.y + 2f, anotherPortalPos.z); transform.position = warpPos; break; } } if (other.gameObject.tag == "Creature" && !other.isTrigger && rigid.velocity.y < -4f) { CreatureMovement creature = other.gameObject.GetComponent <CreatureMovement>(); creature.Die(); Vector2 killVelocity = new Vector2(0, 14f); rigid.AddForce(killVelocity, ForceMode2D.Impulse); ScoreManager.setScore(creature.score); } else if (other.gameObject.tag == "Creature" && !other.isTrigger && !(rigid.velocity.y < -4f) && !isUnBeatTime) { Vector2 attackedVelocity = Vector2.zero; if (other.gameObject.transform.position.x > transform.position.x) { attackedVelocity = new Vector2(-2f, 7f); } else { attackedVelocity = new Vector2(2f, 7f); } rigid.AddForce(attackedVelocity, ForceMode2D.Impulse); health--; if (health > 0) { isUnBeatTime = true; StartCoroutine("UnBeatTime"); } } if (other.gameObject.tag == "Fall") { health = 0; } if (other.gameObject.tag == "Coin") { BlockStatus coin = other.gameObject.GetComponent <BlockStatus>(); ScoreManager.setScore((int)coin.value); Destroy(other.gameObject, 0f); } if (other.gameObject.tag == "End") { GameManager.EndGame(); } if (other.gameObject.tag == "Key") { isKey = true; Destroy(key); } if (other.gameObject.tag == "Prison") { if (isKey) { isPrison = false; Destroy(prison); } } if (other.gameObject.tag == "Zinha") { if (isKey) { if (!isPrison) { GameManager.EndGame(); } } } }
// Update is called once per frame void Update() { if (CreatureLatched == true) { //Victim_Stats = GetComponentInParent<CreatureStats>(); gameObject.transform.position = Victim_Stats.Creature_Stats.LatchPoint.transform.position; rigBod.isKinematic = true; Player_Collider.enabled = false; //PlayStat.CheckStats.player_HP = PlayStat.CheckStats.player_HP + Victim_Stats.Creature_Stats.HPBuff; } //if (CreatureLatched == false) //{ // PlayStat.CheckStats.player_HP = PlayStat.CheckStats.player_HP; // //PlayStat.StartStats(); // //PlayStat.StatsToBuff.player_HP = PlayStat.b_Stats.hitPoints; // //PlayStat.CheckStats.player_HP = PlayStat.b_Stats.hitPoints; // // PlayStat.CheckStats.player_Lifepoints = PlayStat.b_Stats.lifePoints; // //PlayStat.CheckStats.player_JumpForce = PlayStat.b_Stats.jumpForce; // //PlayStat.CheckStats.player_MoveSpeed = PlayStat.b_Stats.moveSpeed; //} Debug.Log("CreatureLatched = " + CreatureLatched); if (WallLatched == true && Input.GetKeyDown(KeyCode.LeftShift)) { //rigBod.constraints = RigidbodyConstraints2D.None; //rigBod.constraints = RigidbodyConstraints2D.FreezeRotation; WallLatched = false; LatchMove.enabled = false; rigBod.constraints = RigidbodyConstraints2D.None; rigBod.constraints = RigidbodyConstraints2D.FreezeRotation; rigBod.gravityScale = 1; PlayCon.enabled = true; Debug.Log("Wall Latch = " + WallLatched); } if (RoofLatched == true && Input.GetKeyDown(KeyCode.LeftShift)) { //rigBod.constraints = RigidbodyConstraints2D.None; //rigBod.constraints = RigidbodyConstraints2D.FreezeRotation; if (CreatureLatched == true) { PlayStat.CheckStats.player_HP = PlayStat.CheckStats.player_HP + Victim_Stats.Creature_Stats.HPBuff; } RoofLatched = false; LatchMove.enabled = false; rigBod.constraints = RigidbodyConstraints2D.None; rigBod.constraints = RigidbodyConstraints2D.FreezeRotation; rigBod.gravityScale = 1; PlayCon.enabled = true; Debug.Log("Roof Latch = " + RoofLatched); } if (Input.GetKeyDown(KeyCode.LeftShift)) { if (CreatureLatched == true) { PlayStat.CheckStats.player_HP = health; CreatureLatched = false; // Debug.Log("Unlatch pls"); StartCoroutine(UnlatchTimer()); transform.parent = null; CreatureLatched = false; CreatureControl.enabled = false; Victim_Stats = null; CreatureControl = null; Player_Collider.enabled = true; //Physics2D.IgnoreCollision(Player_Collider, Prey.gameObject.GetComponent<Collider2D>()); // Prey = null; rigBod.isKinematic = false; if (CreatureControl == true) { CreatureControl.enabled = false; } if (PlayCon.enabled == false) { PlayCon.enabled = true; } } } }
public void OnCollisionEnter2D(Collision2D Other) { if (Other.gameObject.tag == "LatchWall" && Input.GetKey(KeyCode.LeftShift)) { Debug.Log("Roof Latch_Collision = " + RoofLatched); if (WallLatched == false) { WallLatched = true; LatchMove.enabled = true; rigBod.constraints = RigidbodyConstraints2D.FreezePositionX; rigBod.gravityScale = 0; PlayCon.enabled = false; } } if (Other.gameObject.tag == "LatchRoof" && Input.GetKey(KeyCode.LeftShift)) { //Debug.Log("Roof Latch_Collision = " + RoofLatched); if (RoofLatched == false) { RoofLatched = true; LatchMove.enabled = true; rigBod.constraints = RigidbodyConstraints2D.FreezePositionY; rigBod.gravityScale = 0; PlayCon.enabled = false; //Debug.Log("Roof Latch = " + RoofLatched); } } if (Other.gameObject.tag == "Creature" && Input.GetKey(KeyCode.LeftShift)) { if (CreatureLatched == false && UnlatchPls == false) { CreatureLatched = true; //CreatureControl = GetComponentInParent<CreatureMovement>(); transform.parent = Other.transform; CreatureControl = Other.gameObject.GetComponent <CreatureMovement>(); Victim_Stats = Other.gameObject.GetComponent <CManager>(); gameObject.transform.position = Victim_Stats.Creature_Stats.LatchPoint.transform.position; //Prey = Other.gameObject; if (CreatureControl.enabled == false) { CreatureControl.enabled = true; } if (PlayCon.enabled == true) { PlayCon.enabled = false; } if (LatchMove.enabled == true) { LatchMove.enabled = false; } if (Victim_Stats.Hived == false) { //PlayStat.CheckStats.player_Lifepoints += 1; PlayStat.CheckStats.player_Lifepoints += 1; Victim_Stats.Hived = true; Debug.Log(Victim_Stats.Hived); } } } if (Other.gameObject.tag == "Spike") { PlayStat.CheckStats.player_HP += -1; } }