// Update is called once per frame new void Update() { base.Update(); if (confused) { float difference = Time.realtimeSinceStartup - confusedTimestamp; if (difference > confuseDuration) { confused = false; if (this.chasingPlayer) { PlayerControls2 player = chasingPlayer; this.chasingPlayer = null; PlayerEnteredSight(player); } } } else if (chasingPlayer) { PlayerControls2 player = chasingPlayer; bool chasingLeft = direction < 0.0; if ((chasingLeft && player.transform.position.x > transform.position.x) || (!chasingLeft && player.transform.position.x < transform.position.x)) { confusedTimestamp = Time.realtimeSinceStartup; confused = true; Run(0.0f); } } }
void PlayerEnteredSight(PlayerControls2 player) { if (this.chasingPlayer == null) { this.chasingPlayer = player; this.direction = player.transform.position.x < transform.position.x ? -1.0f : 1.0f; if(confused == false) Run(this.direction); } }
void Start() { pc2 = player.GetComponent <PlayerControls2>(); restart = false; //Game text does not appear yet restartText.text = ""; gameOverText.text = ""; //start waves SpawnWaves(); }
void OnTriggerEnter2D(Collider2D other) { //if the collision is with player if (other.gameObject.CompareTag("Player")) { //damage player PlayerControls2 player = other.gameObject.GetComponent <PlayerControls2>(); //make player's texture flash red other.gameObject.GetComponent <Flasher>().startFlash(); //damage player player.takeDamage(10); //destroy bullet Destroy(gameObject); } if (other.gameObject.CompareTag("Wall")) { Destroy(gameObject); } }
void Awake() { cameraAnimator = gameObject.GetComponent <Animator>(); playerScript = Player.GetComponent <PlayerControls2>(); handAnimator = Hand.GetComponent <Animator>(); }
void onPlayerFell(PlayerControls2 player) { Application.LoadLevel(Application.loadedLevel); }
public void notifyPlayerWin(PlayerControls2 winner) { Debug.Log("Player " + winner.GetComponent<PlayerOneControls>() != null ? " 1 " : " 2 " + "wins!"); Application.LoadLevel(Application.loadedLevel); }
void PlayerExitedSight(PlayerControls2 player) { if (confused && chasingPlayer == player) chasingPlayer = null; }
void Start() { isPaused = false; movment = GetComponent <PlayerControls2>(); cross = GetComponent <Crosshair>(); }
void Start() { movment = GetComponent <PlayerControls2>(); cross = GetComponent <Crosshair>(); gameOver.SetActive(false); }