Esempio n. 1
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            bp.InsertBomb();
        }

        // input from keyboard
        MoveVector = GetInputVector();

        // normalize by camera
        MoveVector = RotateWithView();

        // move player
        Move();
    }
Esempio n. 2
0
    private void FindTask()
    {
        var option = FindBestOption();

        //print(option);
        // ----- ----- -----
        if (option == OptionNotFound)
        {
            bm.RandomMove();
            return;
        }
        // ----- ----- -----

        var optionPos = GameSystem.GetPosition(option);

        if (option.CompareTag("SMOKE"))
        {
            print("SMOKE");
        }

        if (option.CompareTag("BOMB"))
        {
            var ballPos  = GameSystem.GetPosition(gameObject);
            var relation = GetRelationWithObject(option);

            if (relation.Equals("OnUp"))
            {
                if (bm.FreePosOnRight())
                {
                    bm.goal = new Vector3Int(ballPos.x + 2, 0, ballPos.z);
                }
                else if (bm.FreePosOnLeft())
                {
                    bm.goal = new Vector3Int(ballPos.x - 2, 0, ballPos.z);
                }
                else
                {
                    bm.goal = new Vector3Int(ballPos.x, 0, ballPos.z - 2);
                }
            }

            else if (relation.Equals("OnDown"))
            {
                if (bm.FreePosOnRight())
                {
                    bm.goal = new Vector3Int(ballPos.x + 2, 0, ballPos.z);
                }
                else if (bm.FreePosOnLeft())
                {
                    bm.goal = new Vector3Int(ballPos.x - 2, 0, ballPos.z);
                }
                else
                {
                    bm.goal = new Vector3Int(ballPos.x, 0, ballPos.z + 2);
                }
            }

            else if (relation.Equals("OnLeft"))
            {
                if (bm.FreePosOnUp())
                {
                    bm.goal = new Vector3Int(ballPos.x, 0, ballPos.z + 2);
                }
                else if (bm.FreePosOnDown())
                {
                    bm.goal = new Vector3Int(ballPos.x, 0, ballPos.z - 2);
                }
                else
                {
                    bm.goal = new Vector3Int(ballPos.x + 2, 0, ballPos.z);
                }
            }

            else if (relation.Equals("OnRight"))
            {
                if (bm.FreePosOnUp())
                {
                    bm.goal = new Vector3Int(ballPos.x, 0, ballPos.z + 2);
                }
                else if (bm.FreePosOnDown())
                {
                    bm.goal = new Vector3Int(ballPos.x, 0, ballPos.z - 2);
                }
                else
                {
                    bm.goal = new Vector3Int(ballPos.x - 2, 0, ballPos.z);
                }
            }

            return;
        }

        if (GameSystem.CompareFirstTagLetters(option.tag, "GIFT"))
        {
            var relation = GetRelationWithObject(option);

            if (relation.Equals("OnUp"))
            {
                bm.goal = new Vector3Int(optionPos.x, 0, optionPos.z + 2);
            }

            if (relation.Equals("OnDown"))
            {
                bm.goal = new Vector3Int(optionPos.x, 0, optionPos.z - 2);
            }

            if (relation.Equals("OnLeft"))
            {
                bm.goal = new Vector3Int(optionPos.x - 2, 0, optionPos.z);
            }

            if (relation.Equals("OnRight"))
            {
                bm.goal = new Vector3Int(optionPos.x + 2, 0, optionPos.z);
            }
        }

        if (option.CompareTag("BALL"))
        {
            var dist = GameSystem.GetDistBetween(gameObject, option);

            if (dist <= 1)
            {
                bp.InsertBomb(); bm.RandomMove();
            }
            else if (dist - 2 <= bp.BombPower)
            {
                bp.InsertBomb();
            }
            else
            {
                bm.goal = optionPos;
            }

            return;
        }

        if (option.CompareTag("GREEN"))
        {
            var dist = GameSystem.GetDistBetween(gameObject, option);

            if (dist <= 1)
            {
                bp.InsertBomb(); bm.RandomMove();
            }
            else
            {
                bm.goal = optionPos;
            }

            return;
        }
    }