Ejemplo n.º 1
0
 override protected void FixedUpdate()
 {
     base.FixedUpdate();
     if (isFlying || isBouncing || isFalling)
     {
         return;
     }
     MapController.MapTile tt = MapController.Instance.GetTile(transform.position);
     if (Vector3.Distance(transform.position, tt.GetCenter()) <= pushMove.magnitude * Time.fixedDeltaTime * Speed)
     {
         CheckTile();
     }
     explosionTimer -= Time.fixedDeltaTime;
     Timer          += Time.fixedDeltaTime;
     if (explosionTimer <= 0)
     {
         Explode();
         return;
     }
     if (Timer > AnimationSpeed)
     {
         AnimationPos++;
         AnimationPos %= NumberOfSprites;
         float scale = 1 + 0.05f * ((float)AnimationPos / (float)NumberOfSprites);
         Renderer.gameObject.transform.localScale = new Vector3(scale, scale);
         Timer = 0;
     }
     Renderer.sprite = BombSprites[AnimationPos];
     Rigidbody.MovePosition(transform.position + pushMove * Time.fixedDeltaTime * Speed);
 }
Ejemplo n.º 2
0
    public void SetSpawnPosition(List <MapController.MapTile> spawnPoints)
    {
        if (spawnPoints == null)
        {
            return;
        }
        List <MapController.MapTile> spawns = new List <MapController.MapTile>(spawnPoints);

        for (int i = 0; i < Players.Count; i++)
        {
            PlayerData            pd    = Players[i];
            MapController.MapTile spawn = null;
            if (RandomSpawns)
            {
                spawn = spawns[UnityEngine.Random.Range(0, spawns.Count)];
                spawns.Remove(spawn);
            }
            pd.PlayerMove.FlyToTarget(spawn.GetCenter(), false, true);
        }
    }
Ejemplo n.º 3
0
    protected override void CheckTile()
    {
        MapController.MapTile tt = MapController.Instance.GetTile(transform.position);
        IsOnIce = false;
        switch (tt.Type)
        {
        case TileType.Empty:
            if (gameObject.layer == LayerMask.NameToLayer("FLYING"))
            {
                return;
            }
            gameObject.layer = LayerMask.NameToLayer("FLYING");
            Rigidbody.MovePosition(tt.GetCenter());
            audioSource.PlayOneShot(PlayerData.FallSound);
            PlayerData.Die();
            StartCoroutine(Falling());
            break;

        case TileType.Ice:
            IsOnIce = true;
            break;
        }
    }
Ejemplo n.º 4
0
    protected override void CheckTile()
    {
        Collider2D[] c2ds = Physics2D.OverlapCircleAll(transform.position, HitBox.radius - 0.1f);
        if (Array.Exists(c2ds, x => x.GetComponent <PlayerMove>() != null) == false)
        {
            //noo player so change layer
            gameObject.layer = finalLayer;
        }
        MapController.MapTile tt = MapController.Instance.GetTile(transform.position);
        if (tt.HasBomb && tt.Bomb != this)
        {
            if (isThrown)
            {
                Debug.Log("BOUNCE");
                //go one move space over But on if Space
                TileType nextType = MapController.Instance.GetTileTypeAt(tt.GetCenter() + flyMove);
                if (nextType != TileType.Wall)
                {
                    FlyToTarget(tt.GetCenter() + flyMove, true); //go to next
                }
                else
                {
                    FlyToTarget(transform.position, true); //bounce
                }
            }
            else
            {
                FlyToTarget(transform.position);
                return;
            }
        }
        else if (tt.HasBomb == false)
        {
            tile      = tt;
            tile.Bomb = this;
        }
        switch (tt.Type)
        {
        case TileType.Empty:
            if (gameObject.layer == LayerMask.NameToLayer("FLYING"))
            {
                return;
            }
            isFalling        = true;
            gameObject.layer = LayerMask.NameToLayer("FLYING");
            GetComponent <AudioSource>().PlayOneShot(fallingClip);
            StartCoroutine(Falling());
            tile.Bomb = null;
            break;

        case TileType.Hole:
            explosionTimer     = 12f;
            transform.position = tt.GetCenter();
            Renderer.gameObject.SetActive(false);
            gameObject.layer = LayerMask.NameToLayer("FLYING");
            tile.Bomb        = null;
            StartCoroutine(Hole());
            break;

        case TileType.ArrowUp:
            if (pushMove == Vector3.up)
            {
                return;
            }
            transform.position = tt.GetCenter();
            pushMove           = Vector3.up;
            break;

        case TileType.ArrowDown:
            if (pushMove == Vector3.down)
            {
                return;
            }
            transform.position = tt.GetCenter();
            pushMove           = Vector3.down;
            break;

        case TileType.ArrowLeft:
            if (pushMove == Vector3.left)
            {
                return;
            }
            transform.position = tt.GetCenter();
            pushMove           = Vector3.left;
            break;

        case TileType.ArrowRight:
            if (pushMove == Vector3.right)
            {
                return;
            }
            transform.position = tt.GetCenter();
            pushMove           = Vector3.right;
            break;

        case TileType.Box:
        case TileType.ExplodedBox:
            gameObject.layer = LayerMask.NameToLayer("THROWN");
            break;
        }
    }