Exemple #1
0
 public WindBullet(BulletProperties properties, Tower tower, int elementLevel, Ant focusTarget) : base(properties, tower)
 {
     ElementLevel       = elementLevel;
     FocusTarget        = focusTarget;
     accumulativeDamage = 1f;
     accuracy           = 0f;
 }
Exemple #2
0
    public int TryDestroyTileAt(Vector3Int pos, BulletProperties props = null, bool shouldExplode = false)
    {
        int ore        = 0;
        int tileHealth = 1;

        if (pos.x >= 0 && pos.x < ChunkSize && pos.y >= 0 && pos.y < ChunkSize)
        {
            ore = OreAmount[pos.x, pos.y];
            if (props != null)
            {
                HealthAmount[pos.x, pos.y] -= props.ShotStrength;
            }
            else
            {
                HealthAmount[pos.x, pos.y] -= 4;                 //if props is null, this is probably being destroyed by another explosion
            }
            tileHealth = HealthAmount[pos.x, pos.y];
        }

        if (tileHealth <= 0)
        {
            DTilemap.TryDestroyTileAt(pos, ore, props, shouldExplode);
            ForegroundTilemap.SetTile(pos, null);
        }
        //print("destroyed tile at " + pos + " with ore " + ore);
        //print(tileHealth);
        return(tileHealth);
    }
        private void CreateBullet(params BulletProperties[] properties)
        {
            var id         = BulletProperties.GetId(properties);
            var projectile = new ProjectileBuiltBullet(properties);

            AddProjectile("builtbullet-" + id, projectile);
            AddItem("itembuiltbullet-" + id, new ItemBuiltBullet(properties, projectile));
        }
Exemple #4
0
 public BulletType(Texture2D texture, float damage, int ammoCost, BulletProperties bProp, float defaultVelocity, float frameWidth, float frameRate)
 {
     this.texture = texture;
     this.damage = damage;
     this.properties = bProp;
     this.defaultVelocity = defaultVelocity;
     this.ammoCost = ammoCost;
     this.FrameRate = frameRate;
     this.FrameWidth = frameWidth;
 }
Exemple #5
0
    public void TryDestroyTileAt(Vector3Int target, int ore = 0, BulletProperties props = null, bool shouldExplode = false)
    {
        Vector3 tileCenter = CellToTileCenter(target);

        TileBase         tile  = TargetTilemap.GetTile(target);
        DestructibleTile dTile = tile as DestructibleTile;

        if (dTile != null)
        {
            if (dTile.Destructible)
            {
                if (dTile.DestroyEffect != null)
                {
                    GameObject effect = Instantiate(dTile.DestroyEffect);
                    effect.transform.position = tileCenter;
                }
                bool  tileExplodes = dTile.Explodes;
                float radius       = dTile.ExplodeRadius;

                if (props != null)
                {
                    //if this is an explosive tile, use the explosive multiplier
                    if (tileExplodes)
                    {
                        radius *= props.ExplosiveMultiplier;
                    }
                    //otherwise, if this is an explosive bullet...
                    else if (shouldExplode)
                    {
                        tileExplodes = true;
                        radius       = props.ExplodeRadius;
                    }
                }



                TargetTilemap.SetTile(target, null);
                if (ore > 0)
                {
                    for (int i = 0; i < ore; i++)
                    {
                        OreParticle newOre = Instantiate(OrePrefab);
                        newOre.transform.position = tileCenter;
                        newOre.Target             = PlayerObject;
                    }
                }

                if (tileExplodes)
                {
                    DoExplosion(target, radius);
                }
            }
        }
    }
Exemple #6
0
    public int ProcessBulletHitAt(ContactPoint2D hit, BulletProperties props, bool shouldExplode)
    {
        Vector3 hitPosition = Vector3.zero;

        hitPosition.x = hit.point.x - 0.1f * hit.normal.x;
        hitPosition.y = hit.point.y - 0.1f * hit.normal.y;

        Vector3Int tilePos = TargetTilemap.WorldToCell(hitPosition);

        return(TryDestroyTileAtAllChunks(tilePos, props, shouldExplode));
    }
Exemple #7
0
    public void ShootBullet(Vector2 dir, BulletProperties props = null, bool wasFullCharge = true)
    {
        RB.velocity = dir * BulletSpeed;
        if (props != null)
        {
            Properties     = props;
            _bulletHP      = Properties.ShotPenetration;
            _wasFullCharge = wasFullCharge;

            if (_wasFullCharge)
            {
                this.transform.localScale *= 1.3f;
                SpriteRend.color           = FullChargeColor;
            }
            else
            {
                this.transform.localScale = Vector3.one;
                SpriteRend.color          = NormalColor;
            }
        }
    }
Exemple #8
0
 void Awake()
 {
     lvlUp              = false;
     enemyLvlUp         = false;
     expSlider.maxValue = (float)(expToLevel);
     currentExp         = 0f;
     currentLevel       = 1;
     fireRateLevel      = 1;
     movementSpeedLevel = 1;
     explosionLevel     = 1;
     healthLevel        = 1;
     bulletProperties   = bullet.GetComponent <BulletProperties> ();
     playerHealth       = GameObject.Find("Player").GetComponent <PlayerHealth> ();
     shooting           = GameObject.Find("Shot Spawn").GetComponent <Shooting> ();
     playerMovement     = GameObject.Find("Player").GetComponent <PlayerController> ();
     explosion          = explosive.GetComponent <Explosion> ();
     powerUpSpawn       = GameObject.Find("PowerUps").GetComponent <PowerUpsSpawn> ();
     source             = GetComponent <AudioSource> ();
     // Panoksien alkuperäinen hajonta
     bulletProperties.minSpread = -2f;
     bulletProperties.maxSpread = 2f;
 }
Exemple #9
0
    public int TryDestroyTileAtAllChunks(Vector3Int target, BulletProperties props = null, bool shouldExplode = false)
    {
        if (TileChunk != null)
        {
            Chunk targetChunk = TileChunk;
            while (target.x < 0 && targetChunk != null)
            {
                targetChunk = targetChunk.LeftChunk;
                target.x   += TileChunk.ChunkSize;
            }
            while (target.x >= TileChunk.ChunkSize && targetChunk != null)
            {
                targetChunk = targetChunk.RightChunk;
                target.x   -= TileChunk.ChunkSize;
            }
            while (target.y < 0 && targetChunk != null)
            {
                targetChunk = targetChunk.DownChunk;
                target.y   += TileChunk.ChunkSize;
            }

            while (target.y >= TileChunk.ChunkSize && targetChunk != null)
            {
                targetChunk = targetChunk.UpChunk;
                target.y   -= TileChunk.ChunkSize;
            }

            if (targetChunk != null)
            {
                return(targetChunk.TryDestroyTileAt(target, props, shouldExplode));
            }
        }
        else
        {
            TryDestroyTileAt(target, 0, props, shouldExplode);
            return(1);
        }
        return(1);
    }
Exemple #10
0
 public WoodBullet(BulletProperties properties, Tower tower) : base(properties, tower)
 {
 }
Exemple #11
0
 public FireBullet(BulletProperties properties, Tower tower, int elementLevel) : base(properties, tower)
 {
     ElementLevel   = elementLevel;
     SpeedUp        = elementLevel * 0.1f;
     EffectDuration = 1;
 }
Exemple #12
0
 public PoisonBullet(BulletProperties properties, Tower tower, int elementLevel) : base(properties, tower)
 {
     ElementLevel   = elementLevel;
     Poison         = elementLevel * 1f;
     EffectDuration = elementLevel * 1;
 }
Exemple #13
0
 public ThunderBullet(BulletProperties properties, Tower tower, int elementLevel) : base(properties, tower)
 {
     ElementLevel         = elementLevel;
     ParalysisProbability = Math.Pow(0.1, 1 / (double)elementLevel);
     EffectDuration       = elementLevel * 0.1f;
 }
Exemple #14
0
 public IceBullet(BulletProperties properties, Tower tower, int elementLevel) : base(properties, tower)
 {
     ElementLevel   = elementLevel;
     SlowDownRatio  = elementLevel * 0.2f;
     EffectDuration = elementLevel / 3f;
 }