예제 #1
0
    void OnCollisionExit(Collision collision)
    {
        GameObject hexagonObject = collision.gameObject;

        if(hexagonObject.tag == "Tile")
        {
            HexagonBehaviour leftTile = hexagonObject.GetComponent<HexagonBehaviour>();

            leftTile.GotUnoccupied(this);   // Tell the former occupiedTile, that this ball left
            AnalyseUnoccupiedHexagon(occupiedTile.GetComponent<Hexagon>());
        }
    }
예제 #2
0
    /* ------------------------------ UPDATING AND WAITING FOR INPUT METHODS ------------------------------  */

    /*       
     *  So far just testing stuff
    **/
    // void FixedUpdate()
    // {
    //     // Save current position, not used yet
    //     positions.Add(transform.position);

    //     // Start ghost/replay --- JUST A TEST SO FAR ---
    //     if(Input.GetKeyDown(KeyCode.R))
    //     {                     
    //         transform.position = positions[replayPositionCounter];
    //         replayPositionCounter++;
    //     }
    // }


    /* ------------------------------ CHECKING AND ANALYSING ENVIRONMENT ------------------------------  */

    /*  
     *  The player checks, if it is standing on a tile; if true, then save the currentTile and tell the current and former tile
    **/
    void OnCollisionEnter(Collision collision)
    {        
        GameObject hexagonObject = collision.gameObject;

        if(hexagonObject.tag == "Tile")
        {
            HexagonBehaviour currentTile = hexagonObject.GetComponent<HexagonBehaviour>();
            occupiedTile = currentTile;         // Save the current tile
            currentTile.GotOccupied(this);      // Tell the currentTile, that this player stands on it            
            AnalyseOccupiedHexagon(currentTile.GetComponent<Hexagon>());            
        }
    }
예제 #3
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetButtonDown("Fire") && LevelLogic.arrowCount > 0)
        {
            isShooting = !isShooting;
            updateParticles();
        }



        //INPUT MANAGER
        if (isShooting == false)
        {
            if (Input.GetButtonDown("UpLeft"))
            {
                destHex = homeHex.aboveLeft.GetComponent <HexagonBehaviour> ();

                if ((destHex.inhabitant == null) && (destHex.gameObject.name != "Deadzone"))
                {
                    //Set new Home
                    this.transform.position = homeHex.aboveLeft.transform.position;

                    homeHex.inhabitant = null;
                    homeHex            = destHex;
                    homeHex.inhabitant = this.gameObject;
                    positon            = destHex.gameObject;


                    this.transform.eulerAngles = new Vector3(0, 120, 0);

                    SendMessageUpwards("PlayerMoved");
                }
            }

            if (Input.GetButtonDown("UpRight"))
            {
                destHex = homeHex.aboveRight.GetComponent <HexagonBehaviour> ();

                if ((destHex.inhabitant == null) && (destHex.gameObject.name != "Deadzone"))
                {
                    //Set new Home
                    this.transform.position = homeHex.aboveRight.transform.position;

                    homeHex.inhabitant = null;
                    homeHex            = destHex;
                    homeHex.inhabitant = this.gameObject;
                    positon            = destHex.gameObject;

                    this.transform.eulerAngles = new Vector3(0, -120, 0);

                    SendMessageUpwards("PlayerMoved");
                }
            }

            if (Input.GetButtonDown("Left"))
            {
                destHex = homeHex.left.GetComponent <HexagonBehaviour> ();

                if ((destHex.inhabitant == null) && (destHex.gameObject.name != "Deadzone"))
                {
                    //Set new Home
                    this.transform.position = homeHex.left.transform.position;

                    homeHex.inhabitant = null;
                    homeHex            = destHex;
                    homeHex.inhabitant = this.gameObject;
                    positon            = destHex.gameObject;

                    this.transform.eulerAngles = new Vector3(0, 90, 0);

                    SendMessageUpwards("PlayerMoved");
                }
            }

            if (Input.GetButtonDown("Right"))
            {
                destHex = homeHex.right.GetComponent <HexagonBehaviour> ();

                if ((destHex.inhabitant == null) && (destHex.gameObject.name != "Deadzone"))
                {
                    //Set new Home
                    this.transform.position = homeHex.right.transform.position;

                    homeHex.inhabitant = null;
                    homeHex            = destHex;
                    homeHex.inhabitant = this.gameObject;
                    positon            = destHex.gameObject;

                    this.transform.eulerAngles = new Vector3(0, -90, 0);

                    SendMessageUpwards("PlayerMoved");
                }
            }

            if (Input.GetButtonDown("DownLeft"))
            {
                destHex = homeHex.belowLeft.GetComponent <HexagonBehaviour> ();

                if ((destHex.inhabitant == null) && (destHex.gameObject.name != "Deadzone"))
                {
                    //Set new Home
                    this.transform.position = homeHex.belowLeft.transform.position;

                    homeHex.inhabitant = null;
                    homeHex            = destHex;
                    homeHex.inhabitant = this.gameObject;
                    positon            = destHex.gameObject;

                    this.transform.eulerAngles = new Vector3(0, 30, 0);

                    SendMessageUpwards("PlayerMoved");
                }
            }

            if (Input.GetButtonDown("DownRight"))
            {
                destHex = homeHex.belowRight.GetComponent <HexagonBehaviour> ();

                if ((destHex.inhabitant == null) && (destHex.gameObject.name != "Deadzone"))
                {
                    //Set new Home
                    this.transform.position = homeHex.belowRight.transform.position;

                    homeHex.inhabitant = null;
                    homeHex            = destHex;
                    homeHex.inhabitant = this.gameObject;
                    positon            = destHex.gameObject;

                    this.transform.eulerAngles = new Vector3(0, -30, 0);

                    SendMessageUpwards("PlayerMoved");
                }
            }
        }



        if (isShooting == true)
        {
            if (Input.anyKeyDown && LevelLogic.arrowCount > 0)
            {
                string dir = null;
                destHex = homeHex.GetComponent <HexagonBehaviour> ();

                if (Input.GetButtonDown("UpLeft"))
                {
                    dir = "UpLeft";
                    LevelLogic.arrowCount--;
                    isShooting = false;
                    arrowShoot.Play();
                }

                if (Input.GetButtonDown("UpRight"))
                {
                    dir = "UpRight";
                    LevelLogic.arrowCount--;
                    isShooting = false;
                    arrowShoot.Play();
                }

                if (Input.GetButtonDown("Left"))
                {
                    dir = "Left";
                    LevelLogic.arrowCount--;
                    isShooting = false;
                    arrowShoot.Play();
                }

                if (Input.GetButtonDown("Right"))
                {
                    dir = "Right";
                    LevelLogic.arrowCount--;
                    isShooting = false;
                    arrowShoot.Play();
                }

                if (Input.GetButtonDown("DownLeft"))
                {
                    dir = "DownLeft";
                    LevelLogic.arrowCount--;
                    isShooting = false;
                    arrowShoot.Play();
                }

                if (Input.GetButtonDown("DownRight"))
                {
                    dir = "DownRight";
                    LevelLogic.arrowCount--;
                    isShooting = false;
                    arrowShoot.Play();
                }


                destHex.SendMessage("ShootArrow", dir);
                SendMessageUpwards("UpdateStuff");

                updateParticles();
            }
        }
    }