public void FollowEnemy(Enemy_Minigame enemy) { if(handAIState == HandAIState.NONE) { enemyToFire = enemy; handAIState = HandAIState.FOLLOWING; } }
public void FollowTreasure(Pirate_Treasure treasure) { if(treasureToFollow == null){ treasureToFollow = treasure; handAIState = HandAIState.FOLLOWING; } }
void Start() { //myHandType = TypeHand.TREASURE; handAIState = HandAIState.NONE; }
void EnemyAIUpdate() { if(myHandType == TypeHand.ENEMY) { //if(!GetComponent<UITexture>().enabled) { GetComponent<UITexture>().enabled = true; } if(handAIState == HandAIState.FOLLOWING) { float dist = Vector2.Distance ((Vector2) ship.transform.position, (Vector2)enemyToFire.transform.position); Vector3 enemyPos = enemyToFire.transform.position; if(dist > 0.75f) enemyPos.y -= 0.25f; Vector3 dir = enemyPos - transform.position; dir.Normalize(); transform.Translate(new Vector3(dir.x, dir.y, 0) * handSpeed * Time.deltaTime); if(!reachedDestination && Vector2.Distance ((Vector2) transform.position, (Vector2)enemyPos) < 0.1f) { reachedDestination = true; if(dist < 0.75f) { ship.ShootAtPosition(enemyToFire.transform.position); } else{ ship.ShootAtPosition(enemyPos); } handAIState = HandAIState.PRESSING; //treasureToFollow.TreasurePressed(true); //if(!GetComponent<UITexture>().enabled) { GetComponent<UITexture>().enabled = true; } GetComponent<UITexture>().enabled = true; GetComponent<UITexture>().mainTexture = selectHandTexture; Invoke("UnpressEnemy", 0.5f); } } } }
public void UnselectTreasure() { GetComponent<UITexture>().mainTexture = unselectHandTexture; GetComponent<UITexture>().enabled = false; handAIState = HandAIState.NONE; reachedDestination = false; treasureToFollow = null; }
public void UnpressEnemy() { GetComponent<UITexture>().enabled = false; GetComponent<UITexture>().mainTexture = unselectHandTexture; reachedDestination = false; enemyToFire = null; handAIState = HandAIState.NONE; }