Example #1
0
    private void CreateWallDummies(Coords2 coords, GameObject tile)
    {
        GameObject         wallDummyPrefab = GameManager.instance.GetPrefabs().multitileWallDummy;
        WallTileController controller      = tile.GetComponent <WallTileController>();

        if (controller == null)
        {
            return;
        }
        CreateDummies(coords, tile, wallTileLayer, wallDummyPrefab, controller.GetDummiesToCreate());
    }
Example #2
0
    public override void OnHitWall(WallTileController wall)
    {
        Map     map = GameManager.instance.GetMap();
        Coords2 centerOfExplosion = new Coords2((int)(transform.position.x + 0.5f), (int)(transform.position.y + 0.5f));

        for (int i = -1; i <= 1; i++)
        {
            for (int j = -1; j <= 1; j++)
            {
                map.RemoveWallTile(new Coords2(i, j) + centerOfExplosion);
            }
        }
        GameObject explosion = Instantiate(explosionAnimation, new Vector3(centerOfExplosion.x, centerOfExplosion.y), Quaternion.identity) as GameObject;

        explosion.transform.localScale = new Vector3(2.0f, 2.0f, 2.0f);
        Destroy(explosion, 2.0f);
        isDead = true;
    }
Example #3
0
    //return 1.0f if tile has boxcollider if wall controller is not present or value specified by wallcontroller
    public float Opacity(Coords2 coords)
    {
        GameObject tile = GetWallTile(coords);

        if (tile == null)
        {
            return(0.0f);
        }

        WallTileController controller = tile.GetComponent <WallTileController>();

        if (controller == null)
        {
            return(tile.GetComponent <BoxCollider2D>() != null ? 1.0f : 0.0f);
        }

        return(controller.Opacity());
    }
Example #4
0
    //return true if tile has boxcollider if wall controller is not present or value specified by wallcontroller
    public bool HasCollider(Coords2 coords)
    {
        GameObject tile = GetWallTile(coords);

        if (tile == null)
        {
            return(false);
        }

        WallTileController controller = tile.GetComponent <WallTileController>();

        if (controller == null)
        {
            return(tile.GetComponent <BoxCollider2D>() != null);
        }

        return(controller.HasCollider());
    }
Example #5
0
    private void UpdateBulletsPhysics(BulletController bullet)
    {
        Vector2 position    = bullet.GetPosition();
        Vector2 velocity    = bullet.GetVelocity();
        Vector2 newPosition = position + velocity * Time.fixedDeltaTime;

        bullet.SetPosition(newPosition);
        Rect collider = bullet.GetCollider();

        int minX = Mathf.FloorToInt(collider.xMin + 0.5f);
        int minY = Mathf.FloorToInt(collider.yMin + 0.5f);
        int maxX = Mathf.FloorToInt(collider.xMax + 0.5f);
        int maxY = Mathf.FloorToInt(collider.yMax + 0.5f);

        for (int x = minX; x <= maxX; ++x)
        {
            for (int y = minY; y <= maxY; ++y)
            {
                Coords2    coords = new Coords2(x, y);
                GameObject wall   = map.GetWallTile(coords);
                if (wall == null)
                {
                    continue;
                }
                WallTileController controller = wall.GetComponent <WallTileController>();
                if (controller == null)
                {
                    continue;
                }
                if (controller.HasCollider())
                {
                    bullet.OnHitWall(controller);
                    return;
                }
            }
        }
    }
Example #6
0
    //requires wall to have wallcontroler
    private bool InteractWall(Coords2 coords, Player player)
    {
        GameObject tile = GetWallTile(coords);

        if (tile == null)
        {
            return(false);
        }

        WallTileController controller = tile.GetComponent <WallTileController>();

        if (controller == null)
        {
            return(false);
        }

        bool interacted = controller.Interact(coords, player);

        if (interacted)
        {
            WallTileChanged(coords);
        }
        return(interacted);
    }
Example #7
0
 public override void OnHitWall(WallTileController wall)
 {
     GameManager.instance.GetMap().CreateWallTile(new Coords2((int)(transform.position.x + 0.5f), (int)(transform.position.y + 0.5f)), dirtWallPrefab);
     isDead = true;
 }
Example #8
0
 public virtual void OnHitWall(WallTileController wall)
 {
 }
Example #9
0
 public override void OnHitWall(WallTileController wall)
 {
     isDead = true;
 }
 public void SetOwner(GameObject newOwner)
 {
     ownerController = newOwner.GetComponent <WallTileController>();
 }