public override void Execute(GameObject go) { if (go.GetComponent <CharacterVars> ().currentResource > 0) { if (Vector3.Distance(go.transform.position, target.transform.position) < distanceToDrop) { target.GetComponent <VillageVars> ().currentResources += go.GetComponent <CharacterVars> ().currentResource; go.GetComponent <CharacterVars> ().currentResource = 0; go.GetComponent <NavMeshAgent> ().Stop(); go.transform.rotation = Quaternion.AngleAxis(180, Vector3.up) * go.transform.rotation; } else { Goto.Execute(go); } } }
public override void Execute(GameObject go) { // Can't gather what there no longer is if (TargetResVars().currentResource < 10) { return; } if (Vector3.Distance(go.transform.position, target.transform.position) < gatherDistance) { TargetResVars().currentResource -= 10; go.GetComponent <CharacterVars> ().currentResource += 10; } else { if (Goto == null) { Goto = new GoToTarget(target.transform.position); } Goto.Execute(go); } }
public override void Execute(GameObject go) { Animator anim = go.GetComponent <Animator> (); if (Vector3.Distance(go.transform.position, target.transform.position) < attackDistance) { go.GetComponent <NavMeshAgent> ().Stop(); anim.SetBool("isWalking", false); go.transform.forward = (target.transform.position - go.transform.position).normalized; if (anim.GetCurrentAnimatorStateInfo(0).IsName("Attack") && anim.GetBool("isAttacking")) { TargetCharVars().currentHealth -= 10; target.GetComponent <CharacterScript> ().nextPerceptions.Add(new AttackedMe(self)); anim.SetBool("isAttacking", false); //if(go.tag == "Orc") Debug.Log ("Attack Orc"); //Debug.Log(target); } else if (!anim.GetCurrentAnimatorStateInfo(0).IsName("Attack")) { anim.SetBool("isAttacking", true); } //attackTarget.gameObject.GetComponent<CharacterVars>().currentHealth--; return; } else { Goto.position = target.transform.position; Goto.Execute(go); return; } }