void OnCollisionEnter(UnityEngine.Collision other) { switch (other.gameObject.tag) { case "egg": if (fort == 0) { _chicken.eggsBroken++; _gameManager.lostEggs++; Destroy(other.gameObject); Destroy(gameObject); } else { fort--; } break; case "bucket": _gameManager.collectedEggs++; _gameManager.cash += 0.5f; Destroy(gameObject); break; case "ground": _chicken.eggsBroken++; _gameManager.lostEggs++; Destroy(gameObject); break; case "chicken": _chicken = other.gameObject.GetComponent <ChickenBehaviour>(); break; } }
private void Update() { if (actionsQueue.Count == 0) { AbstractAction action = PickAction(); actionsQueue.Add(action); } currentAction.Execute(); currentAction.Update(); if (currentAction.IsDone()) { currentAction = actionsQueue[0]; actionsQueue.RemoveAt(0); } float deltaTime = Time.deltaTime; transform.localScale += new Vector3(deltaTime, deltaTime, deltaTime) * 2.5f / growDuration; if (transform.localScale.x >= originalScaleX * 2.5f) { ChickenBehaviour newChicken = Instantiate(chicken, transform.position, Quaternion.identity); newChicken.transform.GetChild(0).GetComponent <MeshRenderer>().material.color = transform.GetChild(0).GetComponent <MeshRenderer>().material.color; Destroy(this.gameObject); } }
/* TOOLS */ public void Spawn(Vector3 spawnLocation) { ChickenBehaviour target = Instantiate(targetToSpawn, spawnLocation, Quaternion.Euler(new Vector3(0, Random.Range(-180f, 180f)))); target.transform.GetChild(0).GetComponent <MeshRenderer>().material.color = PickRandomColor(); target.name = "Chicken " + counter; counter++; chickens.Add(target); }
public override void Act(GameObject player, GameObject npc) { npc.GetComponent <Animator>().SetFloat("MoveValue", 0f); if (!actionPerformed) { if (npc.GetComponent <MonoBehaviour>() is ChickenBehaviour) { ChickenBehaviour chicken = npc.GetComponent <MonoBehaviour>() as ChickenBehaviour; chicken.StartCoroutine(chicken.WaitForExplosion()); actionPerformed = true; } } }
public override void Use() { if (useIsAllowed) { base.Use(); Rumble(); GameObject obj = Instantiate(chickenPrefab); ChickenBehaviour chi = obj.GetComponent <ChickenBehaviour>(); chi.OwnerScript = this.OwnerScript; chi.RumbleManager = this.rumbleManager; obj.SetActive(false); NavMeshHit hit; bool found = NavMesh.SamplePosition(transform.position, out hit, 10f, NavMesh.AllAreas); if (found) { obj.transform.position = hit.position; } else { Debug.Log("false"); obj.transform.position = transform.position; } obj.transform.rotation = transform.rotation; obj.SetActive(true); useIsAllowed = false; StartCoroutine(WaitForNextAbility()); } }
public TurnAction(EActionType actionType, ChickenBehaviour context, float angle, float speed) : base(actionType, context) { this.angle = angle; this.speed = speed; }
public AbstractAction(EActionType actionType, ChickenBehaviour context) { this.actionType = actionType; this.context = context; done = false; }
public GoForwardAction(EActionType actionType, ChickenBehaviour context, float distance, float speed) : base(actionType, context) { destination = GetContext().transform.position + GetContext().transform.forward *distance; this.speed = speed; }
public IdleAction(EActionType actionType, ChickenBehaviour context) : base(actionType, context) { duration = Random.Range(GetContext().GetMinIdleDuration(), GetContext().GetMaxIdleDuration()); timer = 0; }