Exemple #1
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        DamagableUnit damagable = collider.GetComponent <DamagableUnit>();

        if (damagable != null && !AlreadyDamagedUnits.Contains(damagable))
        {
            damagable.TakeDamage(3f);
            AlreadyDamagedUnits.Add(damagable);
        }
    }
    public void OnTriggerEnter2D(Collider2D col)
    {
        DamagableUnit u = col.GetComponent <DamagableUnit>();

        if (u != null)
        {
            if (u.gameObject.layer != Owner.gameObject.layer)
            {
                u.TakeDamage(Owner.HitDamage);
            }
        }
    }
    void OnTriggerEnter2D(Collider2D Collider)
    {
        DamagableUnit u = Collider.gameObject.GetComponent <DamagableUnit>();

        if (u != null)
        {
            if (u.gameObject.layer != gameObject.layer)
            {
                u.TakeDamage(HitDamage);
            }
        }
    }
    public IEnumerator EmbiggenEffect(GameObject Unit)
    {
        float   timer           = 1f;
        float   cTimer          = 0f;
        Vector3 initalUnitScale = Unit.transform.localScale;
        Vector3 finalUnitScale  = new Vector3(
            initalUnitScale.x * 1.25f,
            initalUnitScale.y * 1.25f,
            initalUnitScale.y * 1.25f
            );

        while (cTimer < timer)
        {
            if (Unit != null)
            {
                Unit.transform.localScale = Vector3.Lerp(
                    initalUnitScale,
                    finalUnitScale,
                    cTimer / timer
                    );
            }
            cTimer += Time.deltaTime;
            yield return(null);
        }
        if (Unit != null)
        {
            Unit.transform.localScale = finalUnitScale;
            JumpingUnit ju = Unit.GetComponent <JumpingUnit>();
            if (ju != null)
            {
                ju.GroundCheckDistance = ju.GroundCheckDistance * 1.25f;
                ju.Body.mass           = ju.Body.mass * 1.05f;
                ju.JumpForce           = new Vector2(
                    ju.JumpForce.x,
                    ju.JumpForce.y * 1.2f
                    );
            }
            DamagableUnit du = Unit.GetComponent <DamagableUnit>();
            if (du != null)
            {
                du.Hp += 10;
            }
            WizardBehaviour wb = Unit.GetComponent <WizardBehaviour>();
            if (wb != null)
            {
                wb.FireballSpellScale = finalUnitScale;
            }
        }
    }
    public void OnTriggerEnter2D(Collider2D collider)
    {
        DamagableUnit u = collider.gameObject.GetComponent <DamagableUnit>();

        if (u != null)
        {
            u.TakeDamage(999);
        }
        Arrow a = collider.gameObject.GetComponent <Arrow>();

        if (a != null)
        {
            Destroy(a.gameObject);
        }
        Fireball f = collider.gameObject.GetComponent <Fireball>();

        if (f != null)
        {
            Destroy(f.gameObject);
        }
    }
Exemple #6
0
 public void AttackNearbyEnemies()
 {
     RaycastHit2D[] hits = Physics2D.RaycastAll(
         transform.position,
         new Vector2(
             Body.velocity.x / Mathf.Abs(Body.velocity.x),
             0
             ),
         AttackReach
         );
     foreach (RaycastHit2D hit in hits)
     {
         DamagableUnit u = hit.transform.gameObject.GetComponent <DamagableUnit>();
         if (u != null)
         {
             if (u.gameObject.layer != gameObject.layer)
             {
                 Animation.SetTrigger("SoldierAttack");
                 Weapon.gameObject.SetActive(true);
             }
         }
     }
 }
Exemple #7
0
    void Update()
    {
        if (FreezeUpdateLoop)
        {
            return;
        }
        if (Input.GetKey(KeyCode.Space))
        {
            UnitSpawner.SpawnSoldier();
        }
        List <Tile> tilesToRemove = GetRemovableTiles();
        Dictionary <string, int> removedTileCounts = new Dictionary <string, int>();

        if (tilesToRemove.Count > 0)
        {
            foreach (Tile ttr in tilesToRemove)
            {
                if (!removedTileCounts.ContainsKey(ttr.Name))
                {
                    removedTileCounts[ttr.Name] = 0;
                }
                removedTileCounts[ttr.Name]++;
                Vector2 ttrc = GetTileCoordinates(ttr);
                TileMap[(int)ttrc.y][(int)ttrc.x].Tile.Remove();
                TileMap[(int)ttrc.y][(int)ttrc.x].Tile = null;
            }
            if (removedTileCounts.ContainsKey("Sword") ||
                removedTileCounts.ContainsKey("Arrow") ||
                removedTileCounts.ContainsKey("Thunder") ||
                removedTileCounts.ContainsKey("Shield") ||
                removedTileCounts.ContainsKey("Void")
                )
            {
                SfxManagerService.GetInstance().PlayTilePop();
            }
            if (removedTileCounts.ContainsKey("Skull"))
            {
                SfxManagerService.GetInstance().PlaySkullPop();
            }
            if (removedTileCounts.ContainsKey("Sword"))
            {
                while (removedTileCounts["Sword"] >= 3)
                {
                    UnitSpawner.SpawnSoldier();
                    removedTileCounts["Sword"] -= 3;
                }
            }
            if (removedTileCounts.ContainsKey("Arrow"))
            {
                while (removedTileCounts["Arrow"] >= 3)
                {
                    UnitSpawner.SpawnArcher();
                    removedTileCounts["Arrow"] -= 3;
                }
            }
            if (removedTileCounts.ContainsKey("Thunder"))
            {
                while (removedTileCounts["Thunder"] >= 3)
                {
                    UnitSpawner.SpawnWizard();
                    removedTileCounts["Thunder"] -= 3;
                }
            }
            if (removedTileCounts.ContainsKey("Void"))
            {
                while (removedTileCounts["Void"] >= 3)
                {
                    if (LevelManagerService.GetInstance().CurrentPlayerMana < 3)
                    {
                        StartCoroutine(IncreaseManaByXOverT(1, 0.5f));
                    }
                    removedTileCounts["Void"] -= 3;
                }
            }
            if (removedTileCounts.ContainsKey("Skull"))
            {
                float skullDamage = Mathf.Min(removedTileCounts["Skull"] / 2);
                while (removedTileCounts["Skull"] >= 3)
                {
                    removedTileCounts["Skull"] -= 3;
                    List <GameObject> PlayerSpawnedUnits = UnitSpawner.GetAllSpawnedUnits();
                    foreach (GameObject u in PlayerSpawnedUnits)
                    {
                        if (u != null)
                        {
                            DamagableUnit d = u.GetComponent <DamagableUnit>();
                            if (d != null)
                            {
                                d.TakeDamage(skullDamage);
                            }
                        }
                    }
                }
            }
            StartCoroutine(PushTiles());
        }
    }