Ejemplo n.º 1
0
 public Player(World _World)
 {
     world  = _World;
     pos    = world.Tiles [0, 0].TilePos;
     intPos = new IntPosition2D(0, 0);
     intPos = IntPosition2D.Vector2ToIntPos2D(pos);
 }
Ejemplo n.º 2
0
    void Update()
    {
        //constant move down
        transform.Translate(Vector2.down * Time.deltaTime * moveSpeed);

        intPos = IntPosition2D.Vector2ToIntPos2D(transform.position);

        if (intPos != lastIntPos)
        {
            bombDroped = false;
        }

        if (intPos.Y == 23)
        {
            lastIntPos = intPos;
        }

        if (!bombDroped && intPos.Y == (lastIntPos.Y - 1))
        {
            FireMissile();


            lastIntPos = intPos;
            bombDroped = true;
        }

        if (transform.position.y <= -5)
        {
            DestroyImmediate(this.gameObject);
        }
    }
Ejemplo n.º 3
0
    void CheckTile(IntPosition2D pos)
    {
        Tile tile = GM.World.Tiles [pos.X, pos.Y];

        if (tile.Deadly)
        {
            player.LoseLife();
        }
    }
Ejemplo n.º 4
0
 void CheckTile(IntPosition2D pos)
 {
     if (GM.World.Tiles [pos.X, pos.Y].Walkable == true)
     {
         tileChosen = true;
         LaunchPlayer();
     }
     else
     {
         ChooseTile();
     }
 }
Ejemplo n.º 5
0
    public static IntPosition2D Vector2ToIntPos2D(Vector2 vector2)
    {
        int           X = 0;
        int           Y = 0;
        IntPosition2D retPos;

        X = Mathf.RoundToInt(vector2.x);
        Y = Mathf.RoundToInt(vector2.y);

        retPos = new IntPosition2D(X, Y);

        return(retPos);
    }
Ejemplo n.º 6
0
 public void MoveDown()
 {
     try
     {
         if (world.Tiles [intPos.X, intPos.Y - 1].Walkable)
         {
             pos    = new Vector2(intPos.X, intPos.Y - 1);
             intPos = IntPosition2D.Vector2ToIntPos2D(pos);
         }
         else if (!world.Tiles [intPos.X, intPos.Y - 1].Walkable)
         {
         }
     } catch
     {
     }
 }
Ejemplo n.º 7
0
 public void MoveLeft()
 {
     try
     {
         if (world.Tiles [intPos.X - 1, intPos.Y].Walkable)
         {
             pos    = new Vector2(intPos.X - 1, intPos.Y);
             intPos = IntPosition2D.Vector2ToIntPos2D(pos);
         }
         else if (!world.Tiles [intPos.X - 1, intPos.Y].Walkable)
         {
             //Debug.Log ("could not move to the left");
         }
     } catch
     {
         //Debug.Log ("could not move to the left");
     }
 }
Ejemplo n.º 8
0
    void Update()
    {           //constant move down
        transform.Translate(Vector2.down * Time.deltaTime * moveSpeed);

        intPos = IntPosition2D.Vector2ToIntPos2D(transform.position);


        //makes sure a bomb is dropped in every tile

        if (intPos != lastIntPos)
        {
            bombDroped = false;
        }

        if (intPos.Y == 23 + (endGame.transform.position.y))
        {
            lastIntPos = intPos;
        }

        if (!bombDroped && intPos.Y == (lastIntPos.Y - 1))
        {
            for (int i = 0; i < spawnPoints.Length; i++)
            {
                DropBomb(spawnPoints [i]);
            }

            lastIntPos = intPos;
            bombDroped = true;
        }

        if (transform.position.y <= -3)
        {
            laneControl.SomthingInLane = false;
            DestroyImmediate(this.gameObject);
        }
    }
Ejemplo n.º 9
0
 void Start()
 {
     lastIntPos = new IntPosition2D(0, 0);
 }
Ejemplo n.º 10
0
 void ChooseTile()
 {
     targetIntPos = new IntPosition2D(Random.Range(0, 11), intPos.Y + range);
     CheckTile(targetIntPos);
 }
Ejemplo n.º 11
0
 void Start()
 {
     GM           = GameObject.Find("GameMaster").GetComponent <GameMaster> ();
     intPos       = IntPosition2D.Vector2ToIntPos2D(transform.position);
     catapultAnim = GetComponent <Animator> ();
 }
Ejemplo n.º 12
0
 void Start()
 {
     lastIntPos = new IntPosition2D(0, 0);
     endGame    = GameObject.Find("EndGame");
 }
Ejemplo n.º 13
0
    void UpdateTunneling()
    {
        //get the end tile based on hov many shovels the player is carrying
        int travelTilesAmount;

        travelTilesAmount = tunnelDistance;
        IntPosition2D endPos = new IntPosition2D(player.IntPos.X, player.IntPos.Y + travelTilesAmount);

        //check if end tile is walkable

        try
        {
            if (GM.World.Tiles [endPos.X, endPos.Y].Walkable == true)
            {
                Debug.Log("i can tunnel to the end!");
                canTunnel = true;
            }
            else
            {
                Debug.Log("i Can't tunnel to the end");
                canTunnel = false;
            }
        } catch
        {
            canTunnel = false;
        }


        //transport player && remove shovels
        if (Input.GetKeyDown(KeyCode.Q))
        {
            actionStates = ActionStates.idle;
            canTunnel    = false;
            tunnel       = false;
        }
        if (canTunnel && !tunnel && Input.GetKeyDown(KeyCode.Alpha1))
        {
            hudGizmos.clearHUD = true;
            StunPlayer();
            playerAnim.SetBool("DigDown", true);
            tunnel         = true;
            player.Imortal = true;
        }

        if (tunnel)
        {
            if (tpPlayer(new Vector2(endPos.X, endPos.Y), 0.5f))
            {
                shovelCount--;
                playerAnim.SetBool("DigDown", false);
            }

            if (DeStunPlayerDelay(0.9f))
            {
                canTunnel          = false;
                tunnel             = false;
                player.Imortal     = false;
                tpDelayTimer       = 0f;
                hudGizmos.clearHUD = false;
                actionStates       = ActionStates.idle;
            }
        }
    }