コード例 #1
0
ファイル: Ant.cs プロジェクト: DSobscure/IANT
        public void PoisonEffect(PoisonBullet bullet)
        {
            float maxDuration = 5f * bullet.ElementLevel * (1 - Resistant);;
            float maxPoison   = 3 * bullet.ElementLevel * (1 - Resistant);;

            if (PoisonEffectDuration + bullet.EffectDuration > maxDuration)
            {
                PoisonEffectDuration = Math.Max(PoisonEffectDuration, maxDuration);
            }
            else
            {
                PoisonEffectDuration = PoisonEffectDuration + bullet.EffectDuration;
            }
            if (Poison + bullet.Poison > maxPoison)
            {
                Poison = Math.Max(Poison, maxPoison);
            }
            else
            {
                Poison = Poison + bullet.Poison;
            }
            if (poisonHP == 0)
            {
                poisonHP = HP;
            }
        }
コード例 #2
0
    /* Shoot()
     *
     * shoots a bullet towards target
     *
     */
    void Shoot()
    {
        GameObject bulletGO = (GameObject)Instantiate(bulletPrefab, firePoint.position, firePoint.rotation);
        // kind of annoying - havce to do this for every GO soooo
        Bullet       bullet     = bulletGO.GetComponent <Bullet>();
        Missile      missile    = bulletGO.GetComponent <Missile>();
        PoisonBullet poisBullet = bulletGO.GetComponent <PoisonBullet>();

        Destroy(bullet, 5f);
        Destroy(missile, 5f);
        Destroy(poisBullet, 5f);
        if (bullet != null)
        {
            bullet.Seek(target);
        }
        if (missile != null)
        {
            missile.Seek(target);
        }
        if (poisBullet != null)
        {
            poisBullet.Seek(target);
        }
    }
コード例 #3
0
        public virtual bool Fire(out Bullet[] bullets)
        {
            if (TargetAimed != null && TargetAimed.HP > 0 && !InReloading)
            {
                if (Range + 32f < DistanceFrom(TargetAimed.PositionX, TargetAimed.PositionY))
                {
                    TargetExitRange(TargetAimed);
                    return(Fire(out bullets));
                }
                else
                {
                    InReloading = true;
                    bullets     = new Bullet[BulletNumber];
                    for (int i = 0; i < BulletNumber; i++)
                    {
                        BulletProperties bulletProperties = new BulletProperties
                        {
                            damage       = Damage,
                            elementType  = ElementType,
                            isPenetrable = false,
                            positionX    = PositionX,
                            positionY    = PositionY,
                            speed        = Speed,
                            rotation     = Convert.ToSingle(Math.Atan2(TargetAimed.PositionY - PositionY, TargetAimed.PositionX - PositionX) * 180.0 / Math.PI - BulletSpanRange * (BulletNumber - 1) / 2.0 + BulletSpanRange * i)
                        };
                        switch (ElementType)
                        {
                        case ElelmentType.Normal:
                            bullets[i] = new Bullet(bulletProperties, this);
                            break;

                        case ElelmentType.Ice:
                            bullets[i] = new IceBullet(bulletProperties, this, ElementLevel);
                            break;

                        case ElelmentType.Fire:
                            bullets[i] = new FireBullet(bulletProperties, this, ElementLevel);
                            break;

                        case ElelmentType.Thunder:
                            bulletProperties.isPenetrable = true;
                            bullets[i] = new ThunderBullet(bulletProperties, this, ElementLevel);
                            break;

                        case ElelmentType.Wind:
                            bullets[i] = new WindBullet(bulletProperties, this, ElementLevel, TargetAimed);
                            break;

                        case ElelmentType.Poison:
                            bulletProperties.isPenetrable = true;
                            bullets[i] = new PoisonBullet(bulletProperties, this, ElementLevel);
                            break;

                        case ElelmentType.Wood:
                            bullets[i] = new WoodBullet(bulletProperties, this);
                            break;
                        }
                    }
                    return(true);
                }
            }
            else
            {
                TargetAimed = null;
                bullets     = null;
                return(false);
            }
        }