Exemplo n.º 1
0
Arquivo: Unit.cs Projeto: 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);
        }