Exemplo n.º 1
0
        internal override void Process()
        {
            var go = this.Device.Player.GameObjectManager.GetBuilderVillageGameObjectByID(this.BuildingID);

            if (go != null)
            {
                Builder_Building            b = (Builder_Building)go;
                Unit_Storage_V2_Componenent c = b.GetUnitStorageV2Component();
                c?.AddUnit(this.Unit);
            }
        }
Exemplo n.º 2
0
        public override void Process()
        {
            var go = Device.Player.GameObjectManager.GetGameObjectByID(BuildingID, true);

            if (go != null)
            {
                Builder_Building            b = (Builder_Building)go;
                Unit_Storage_V2_Componenent c = b.GetUnitStorageV2Component();
                c?.AddUnit(Unit);
            }
        }
Exemplo n.º 3
0
        internal override void Process()
        {
            if (this.Device.Player.Avatar.Variables.IsBuilderVillage)
            {
                List <Component> components = this.Device.Player.GetComponentManager.GetComponents(11);

                foreach (Component t in components)
                {
                    Unit_Storage_V2_Componenent c = (Unit_Storage_V2_Componenent)t;
                    if (c.GetUnitTypeIndex(this.Troop) != -1)
                    {
                        var storageCount = c.GetUnitCountByData(this.Troop);
                        if (storageCount >= 1)
                        {
                            c.RemoveUnits(this.Troop, 1);
                            break;
                        }
                    }
                }
            }
            else
            {
                List <Slot> _PlayerUnits = this.Device.Player.Avatar.Units;

                Slot _DataSlot = _PlayerUnits.Find(t => t.Data == GlobalId);
                if (_DataSlot != null)
                {
                    _DataSlot.Count -= 1;
                }
            }

            if (this.Device.State == State.IN_PC_BATTLE)
            {
                if (!this.Device.Player.Avatar.Variables.IsBuilderVillage && !this.Device.Player.Avatar.Modes.IsAttackingOwnBase)
                {
                    var            Battle  = Core.Resources.Battles.Get(this.Device.Player.Avatar.Battle_ID);
                    Battle_Command Command =
                        new Battle_Command
                    {
                        Command_Type = this.Identifier,
                        Command_Base =
                            new Command_Base
                        {
                            Base = new Base {
                                Tick = this.Tick
                            },
                            Data = this.GlobalId,
                            X    = this.X,
                            Y    = this.Y
                        }
                    };
                    Battle.Add_Command(Command);


                    int Index = Battle.Replay_Info.Units.FindIndex(T => T[0] == this.GlobalId);
                    if (Index > -1)
                    {
                        Battle.Replay_Info.Units[Index][1]++;
                    }
                    else
                    {
                        Battle.Replay_Info.Units.Add(new[] { this.GlobalId, 1 });
                    }

                    Battle.Attacker.Add_Unit(GlobalId, 1);
                }
            }
            else if (this.Device.State == State.IN_1VS1_BATTLE)
            {
                var Battle = Resources.Battles_V2.GetPlayer(this.Device.Player.Avatar.Battle_ID_V2,
                                                            this.Device.Player.Avatar.UserId);

                Battle_Command Command =
                    new Battle_Command
                {
                    Command_Type = this.Identifier,
                    Command_Base =
                        new Command_Base
                    {
                        Base = new Base {
                            Tick = this.Tick
                        },
                        Data = this.GlobalId,
                        X    = this.X,
                        Y    = this.Y
                    }
                };
                int Index = Battle.Replay_Info.Units.FindIndex(T => T[0] == this.GlobalId);
                if (Index > -1)
                {
                    Battle.Replay_Info.Units[Index][1]++;
                }
                else
                {
                    Battle.Replay_Info.Units.Add(new[] { this.GlobalId, 1 });
                }
                Battle.Add_Command(Command);
            }
        }