Exemple #1
0
        public Effect(SpriteInfo si, EffectState state, SpriteDestroyedHandler handler)
            : base(si)
        {
            this.type = state.type;
            this.position = state.position;
            this.startFrame = state.startFrame;
            this.endFrame = state.endFrame;
            this.attachedTankIndex = state.attachedTankIndex;
            scale = 1;
            if (!normalScale.Contains(type))
                scale = 0.6f;

            origin.X = (int)(si.frameSize.X / 2);
            origin.Y = (int)(si.frameSize.Y / 2);
            lastingTime = state.lastingTime;
            if (lastingTime == 0)
                oneTimeEffect = true;
            if (!state.oldEffect)
                SetFrame(state.startFrame);
            else
                SetFrame(state.currentFrame);
            hasBeenDestroyed = handler;
        }
Exemple #2
0
        // Private methods
        void Activate(Dictionary<byte, Tank> tanks, byte tIndex)
        {
            UserTank uT = tanks[tIndex] as UserTank;
            if (uT != null && uT.PlayerIndex == 0)
            {
                needDisplayInfo = true;
            }
            EffectState state = new EffectState()
            {
                attachedTankIndex = 0xff,
                endFrame = new Point(1, 0),
                lastingTime = 3000
            };
            switch (type)
            {
                case ItemType.MaxTankSpeed:
                    oldValue = tanks[tIndex].Speed;
                    tanks[tIndex].Speed = Tank.MaxTankSpeed;
                    GetInfoPositions(ItemCategory.TankSpeed, ref position, ref stringPosition);
                    break;
                case ItemType.IncreaseTankSpeed:
                    tanks[tIndex].Speed += 1;
                    GetInfoPositions(ItemCategory.TankSpeed, ref position, ref stringPosition);
                    state.type = EffectType.II_IncreaseTankSpeed;
                    state.position = position;
                    Factory.CreateEffect(state);
                    OnDestroyed();
                    break;
                case ItemType.MinTankSpeed:
                    oldValue = tanks[tIndex].Speed;
                    tanks[tIndex].Speed = Tank.MinTankSpeed;
                    GetInfoPositions(ItemCategory.TankSpeed, ref position, ref stringPosition);
                    break;
                case ItemType.MinimizeEnemiesTanksSpeed:
                    ActivateUponEnemiesTanks(tanks, tanks[tIndex].Team, ItemType.MinTankSpeed);
                    OnDestroyed();
                    break;

                case ItemType.MaxAmmoSpeed:
                    oldValue = tanks[tIndex].AmmoSpeed;
                    tanks[tIndex].AmmoSpeed = Tank.MaxAmmoSpeed;
                    GetInfoPositions(ItemCategory.AmmoSpeed, ref position, ref stringPosition);
                    break;
                case ItemType.IncreaseAmmoSpeed:
                    tanks[tIndex].AmmoSpeed += 1;
                    GetInfoPositions(ItemCategory.AmmoSpeed, ref position, ref stringPosition);
                    state.type = EffectType.II_IncreaseAmmoSpeed;
                    state.position = position;
                    Factory.CreateEffect(state);
                    OnDestroyed();
                    break;
                case ItemType.MinAmmoSpeed:
                    oldValue = tanks[tIndex].AmmoSpeed;
                    tanks[tIndex].AmmoSpeed = Tank.MinAmmoSpeed;
                    GetInfoPositions(ItemCategory.AmmoSpeed, ref position, ref stringPosition);
                    break;
                case ItemType.MinimizeEnemiesTanksAmmoSpeed:
                    ActivateUponEnemiesTanks(tanks, tanks[tIndex].Team, ItemType.MinAmmoSpeed);
                    OnDestroyed();
                    break;

                case ItemType.MaxArmor:
                    oldValue = tanks[tIndex].Armor;
                    tanks[tIndex].Armor = Tank.MaxArmor;
                    GetInfoPositions(ItemCategory.Armor, ref position, ref stringPosition);
                    break;
                case ItemType.IncreaseArmor:
                    tanks[tIndex].Armor += 5;
                    GetInfoPositions(ItemCategory.Armor, ref position, ref stringPosition);
                    state.type = EffectType.II_IncreaseArmor;
                    state.position = position;
                    Factory.CreateEffect(state);
                    OnDestroyed();
                    break;
                case ItemType.MinArmor:
                    oldValue = tanks[tIndex].Armor;
                    tanks[tIndex].Armor = Tank.MinArmor;
                    GetInfoPositions(ItemCategory.Armor, ref position, ref stringPosition);
                    break;
                case ItemType.MinimizeEnemiesTanksArmor:
                    ActivateUponEnemiesTanks(tanks, tanks[tIndex].Team, ItemType.MinArmor);
                    OnDestroyed();
                    break;

                case ItemType.MinTBF:
                    oldValue = tanks[tIndex].TimeBetweenFires;
                    tanks[tIndex].TimeBetweenFires = Tank.MinTBF;
                    GetInfoPositions(ItemCategory.TBF, ref position, ref stringPosition);
                    break;
                case ItemType.DecreaseTBF:
                    tanks[tIndex].TimeBetweenFires -= 100;
                    GetInfoPositions(ItemCategory.TBF, ref position, ref stringPosition);
                    state.type = EffectType.II_DecreaseTBF;
                    state.position = position;
                    Factory.CreateEffect(state);
                    OnDestroyed();
                    break;
                case ItemType.MaxTBF:
                    oldValue = tanks[tIndex].TimeBetweenFires;
                    tanks[tIndex].TimeBetweenFires = Tank.MaxTBF;
                    GetInfoPositions(ItemCategory.TBF, ref position, ref stringPosition);
                    break;
                case ItemType.MaximizeEnemiesTBF:
                    ActivateUponEnemiesTanks(tanks, tanks[tIndex].Team, ItemType.MaxTBF);
                    OnDestroyed();
                    break;

                case ItemType.Add50Health:
                    tanks[tIndex].Health += 50;
                    OnDestroyed();
                    break;
                case ItemType.MakeTankInvulnerable:
                    tanks[tIndex].InvulnerableTime = activeTime;
                    OnDestroyed();
                    break;
                case ItemType.ChangeAmmoToRocket:
                    tanks[tIndex].AmmoType = AmmoType.Rocket;
                    OnDestroyed();
                    break;
                case ItemType.ChangeAmmoToFireBall:
                    tanks[tIndex].AmmoType = AmmoType.FireBall;
                    OnDestroyed();
                    break;
                case ItemType.ChangeAmmoToPhiTieu:
                    tanks[tIndex].AmmoType = AmmoType.PhiTieu;
                    OnDestroyed();
                    break;
                case ItemType.FreezeAllEnemiesTanks:
                    foreach (var t in tanks.Values)
                        if (t.Team != tanks[tIndex].Team)
                            t.FreezeTime = activeTime;
                    OnDestroyed();
                    break;
            }
            affectedTankIndex = tIndex;
            activated = true;
            waitingTime = 0;
        }
Exemple #3
0
        public static void CreateEffect(EffectState state)
        {
            SpriteInfo si = effectSpriteInfo[state.type];
            Effect e = new Effect(si, state, destroyed);

            created(e);
        }