public Player(World _World) { world = _World; pos = world.Tiles [0, 0].TilePos; intPos = new IntPosition2D(0, 0); intPos = IntPosition2D.Vector2ToIntPos2D(pos); }
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); } }
void CheckTile(IntPosition2D pos) { Tile tile = GM.World.Tiles [pos.X, pos.Y]; if (tile.Deadly) { player.LoseLife(); } }
void CheckTile(IntPosition2D pos) { if (GM.World.Tiles [pos.X, pos.Y].Walkable == true) { tileChosen = true; LaunchPlayer(); } else { ChooseTile(); } }
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); }
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 { } }
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"); } }
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); } }
void Start() { lastIntPos = new IntPosition2D(0, 0); }
void ChooseTile() { targetIntPos = new IntPosition2D(Random.Range(0, 11), intPos.Y + range); CheckTile(targetIntPos); }
void Start() { GM = GameObject.Find("GameMaster").GetComponent <GameMaster> (); intPos = IntPosition2D.Vector2ToIntPos2D(transform.position); catapultAnim = GetComponent <Animator> (); }
void Start() { lastIntPos = new IntPosition2D(0, 0); endGame = GameObject.Find("EndGame"); }
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; } } }