Esempio n. 1
0
    // 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);
            }
        }
    }
Esempio n. 2
0
    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);
        }
    }
Esempio n. 3
0
    void Start()
    {
        pc2     = player.GetComponent <PlayerControls2>();
        restart = false;

        //Game text does not appear yet
        restartText.text  = "";
        gameOverText.text = "";

        //start waves
        SpawnWaves();
    }
Esempio n. 4
0
    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);
        }
    }
Esempio n. 5
0
 void Awake()
 {
     cameraAnimator = gameObject.GetComponent <Animator>();
     playerScript   = Player.GetComponent <PlayerControls2>();
     handAnimator   = Hand.GetComponent <Animator>();
 }
Esempio n. 6
0
 void onPlayerFell(PlayerControls2 player)
 {
     Application.LoadLevel(Application.loadedLevel);
 }
Esempio n. 7
0
 public void notifyPlayerWin(PlayerControls2 winner)
 {
     Debug.Log("Player " + winner.GetComponent<PlayerOneControls>() != null ? " 1 " : " 2 " + "wins!");
     Application.LoadLevel(Application.loadedLevel);
 }
Esempio n. 8
0
 void PlayerExitedSight(PlayerControls2 player)
 {
     if (confused && chasingPlayer == player)
         chasingPlayer = null;
 }
Esempio n. 9
0
 void Start()
 {
     isPaused = false;
     movment  = GetComponent <PlayerControls2>();
     cross    = GetComponent <Crosshair>();
 }
Esempio n. 10
0
 void Start()
 {
     movment = GetComponent <PlayerControls2>();
     cross   = GetComponent <Crosshair>();
     gameOver.SetActive(false);
 }