예제 #1
0
파일: Unit.cs 프로젝트: rio900/voins
        public IUnit RemoveUnit(IUnit demagedUnit)
        {
            Dead       = true;
            IsUnitStun = false;

            IUnit returnUnit = this;

            Player player = demagedUnit as Player;

            if (player == null && demagedUnit is Unit)
            {
                player = (demagedUnit as Unit).MasterPlayer;
            }

            if (player != null)
            {
                player.GetAward(this);

                if (this.GameObject.EnumCallType == EnumCallType.UnitBlock)
                {
                    player.StatisticData.BlockKills += 1;
                }
                if (this.GameObject.EnumCallType == EnumCallType.Unit)
                {
                    player.StatisticData.MobKills += 1;
                }
            }

            var call = CurrentMap.Calls.Single(p => p.IndexLeft == PositionX && p.IndexTop == PositionY);

            call.IUnits.Remove(this);
            if (!call.IUnits.Any())
            {
                call.Used = false;
            }
            CurrentMap.GameObjectInCall.Remove(this.GameObject);

            #region Отображение предмета на месте убитого юнита
            if (this.NItem != null)
            {
                ItemClass item = this.NItem;
                call.Item.Add(item);
                item.PositionX = PositionX;
                item.PositionY = PositionY;
                item.ItemPosition();
                item.View.ApplayMargin(new Thickness(8));
                CurrentMap.MapCanvas.Children.Add(item.View);

                ///Тут будет анимироватся
                CurrentMap.MapCanvas.Children.Remove(this.GameObject.View);
                returnUnit = this;
            }
            #endregion
            if (DeadEvent != null)
            {
                DeadEvent(this, null);
            }

            if (this.GameObject.EnumCallType == EnumCallType.UnitBlock &&
                CurrentMap.BlockBonusGame &&
                player != null)
            {
                int bonusGamePoint = CurrentMap.CheckNumber(this);
                player.PlayerGamePoint = NGamePoint + bonusGamePoint;
            }
            // else
            ///Тут будет анимироватся
            CurrentMap.MapCanvas.Children.Remove(this.GameObject.View);

            foreach (var item in this.Spells)
            {
                IMoveSpell itemMove = item as IMoveSpell;
                if (itemMove != null)
                {
                    itemMove.StopMoveSpell();
                }
            }

            if (this.AI != null)
            {
                this.AI.StopAI();
                this.AI = null;
            }
            DeleteUnit();

            UnitGenerator.Soul(demagedUnit, this);

            return(returnUnit);
        }
예제 #2
0
        public IUnit RemoveUnit(IUnit demagedUnit)
        {
            Dead       = true;
            IsUnitStun = false;

            IUnit returnUnit = this;

            if (demagedUnit != null)
            {
                demagedUnit.Kills += 1;
            }
            Player player = demagedUnit as Player;

            if (player != null)
            {
                player.GetAward(this);
            }
            Death += 1;

            this.Gold -= StaticVaribl.PlayerGoldMinus * this.Level;
            if (this.Gold < 0)
            {
                this.Gold = 0;
            }

            var call = CurrentMap.Calls.Single(p => p.IndexLeft == PositionX && p.IndexTop == PositionY);

            call.IUnits.Remove(this);
            CurrentMap.DeadPlayers.Add(this);

            StopRegenerationTimer();

            if (!call.IUnits.Any())
            {
                call.Used = false;
            }
            //CurrentMap.GameObjectInCall.Remove(this.GameObject);

            #region Отображение предмета на месте убитого юнита
            if (this.NItem != null)
            {
                ItemClass item = this.NItem;
                call.Item.Add(item);
                item.PositionX = PositionX;
                item.PositionY = PositionY;
                item.ItemPosition();
                item.View.ApplayMargin(new Thickness(8));
                CurrentMap.MapCanvas.Children.Add(item.View);
            }
            #endregion

            ///Тут будет анимироватся
            CurrentMap.MapCanvas.Children.Remove(this.GameObject.View);

            foreach (var item in this.Spells)
            {
                IMoveSpell itemMove = item as IMoveSpell;
                if (itemMove != null)
                {
                    itemMove.StopMoveSpell();
                }
            }

            if (DeadEvent != null)
            {
                DeadEvent(this, null);
            }

            if (AllowRespaum)
            {
                ///Таймер воскрешения
                _respaumTimer = new Storyboard()
                {
                    Duration = TimeSpan.FromSeconds(RespaumTime)
                };
                _respaumTimer.Completed += _respaumTimer_Tick;
                _respaumTimer.Begin();
            }

            UnitGenerator.Soul(demagedUnit, this);

            return(returnUnit);
        }