コード例 #1
0
        public void AddUnitToQueue(CombatItemData cd, int count)
        {
            for (int i = 0; i < m_vUnits.Count; i++)
            {
                if ((CombatItemData)m_vUnits[i].Data == cd)
                {
                    if (count != 1)
                    {
                        m_vUnits[i].Value += count;
                        return;
                    }
                    else
                    {
                        m_vUnits[i].Value++;
                        return;
                    }
                }
            }

            DataSlot ds = new DataSlot(cd, count);

            m_vUnits.Add(ds);

            if (m_vTimer == null)
            {
                m_vTimer = new Timer();
                int trainingTime = cd.GetTrainingTime(m_vLevel.GetPlayerAvatar().GetUnitUpgradeLevel(cd));
                m_vTimer.StartTimer(trainingTime, m_vLevel.GetTime());
            }
        }
コード例 #2
0
        internal override void Process()
        {
            List <DataSlot> _PlayerUnits  = this.Device.Player.Avatar.GetUnits();
            List <DataSlot> _PlayerSpells = this.Device.Player.Avatar.GetSpells();

            foreach (UnitToRemove _Unit in UnitsToRemove)
            {
                if (_Unit.Data.ToString().StartsWith("400"))
                {
                    CombatItemData _Troop    = (CombatItemData)CSVManager.DataTables.GetDataById(_Unit.Data);;
                    DataSlot       _DataSlot = _PlayerUnits.Find(t => t.Data.GetGlobalID() == _Troop.GetGlobalID());
                    if (_DataSlot != null)
                    {
                        _DataSlot.Value = _DataSlot.Value - _Unit.Count;
                    }
                }
                else if (_Unit.Data.ToString().StartsWith("260"))
                {
                    SpellData _Spell    = (SpellData)CSVManager.DataTables.GetDataById(_Unit.Data);;
                    DataSlot  _DataSlot = _PlayerSpells.Find(t => t.Data.GetGlobalID() == _Spell.GetGlobalID());
                    if (_DataSlot != null)
                    {
                        _DataSlot.Value = _DataSlot.Value - _Unit.Count;
                    }
                }
            }
        }
コード例 #3
0
 public bool CanAddUnitToQueue(CombatItemData cd)
 {
     //Console.WriteLine(GetMaxTrainCount());
     //Console.WriteLine(GetTotalCount());
     //Console.WriteLine(cd.GetHousingSpace());
     return(GetMaxTrainCount() >= GetTotalCount() + cd.GetHousingSpace());
 }
コード例 #4
0
 public PlaceAttackerCommand(PacketReader br)
 {
     X    = br.ReadInt32();
     Y    = br.ReadInt32();
     Unit = (CombatItemData)br.ReadDataReference();
     Tick = br.ReadUInt32();
 }
コード例 #5
0
        public void AddUsedTroop(CombatItemData cid, int value)
        {
            if (State == UserState.PVP)
            {
                var info = default(AttackInfo);
                if (!AttackingInfo.TryGetValue(GetId(), out info))
                {
                    Logger.Error("Unable to obtain attack info.");
                }
                else
                {
                    var dataSlot = info.UsedTroop.Find(t => t.Data.GetGlobalID() == cid.GetGlobalID());

                    if (dataSlot != null)
                    {
                        // Troops already exist.
                        int i = info.UsedTroop.IndexOf(dataSlot);
                        dataSlot.Value    = dataSlot.Value + value;
                        info.UsedTroop[i] = dataSlot;
                    }
                    else
                    {
                        DataSlot ds = new DataSlot(cid, value);
                        info.UsedTroop.Add(ds);
                    }
                }
            }
            //else
            //  Logger.Write("Unsupported state! AddUsedTroop only for PVP for now.PVE Comming Soon");
        }
コード例 #6
0
        }                                  //FF FF FF FF

        public override void Execute(Level level)
        {
            GameObject go = level.GameObjectManager.GetGameObjectByID(BuildingId);

            if (Count > 0)
            {
                Building b = (Building)go;
                UnitProductionComponent c   = b.GetUnitProductionComponent();
                CombatItemData          cid = (CombatItemData)ObjectManager.DataTables.GetDataById(UnitType);
                do
                {
                    if (!c.CanAddUnitToQueue(cid))
                    {
                        break;
                    }
                    ResourceData trainingResource = cid.GetTrainingResource();
                    ClientAvatar ca           = level.GetHomeOwnerAvatar();
                    int          trainingCost = cid.GetTrainingCost(ca.GetUnitUpgradeLevel(cid));
                    if (!ca.HasEnoughResources(trainingResource, trainingCost))
                    {
                        break;
                    }
                    ca.SetResourceCount(trainingResource, ca.GetResourceCount(trainingResource) - trainingCost);
                    c.AddUnitToProductionQueue(cid);
                    Count--;
                }while (Count > 0);
            }
        }
コード例 #7
0
        public override void Execute(Level level)
        {
            List <DataSlot> units  = level.GetPlayerAvatar().GetUnits();
            List <DataSlot> spells = level.GetPlayerAvatar().GetSpells();

            foreach (UnitToRemove unitToRemove in UnitsToRemove)
            {
                if (unitToRemove.Data.ToString().StartsWith("400"))
                {
                    CombatItemData _Troop   = (CombatItemData)CSVManager.DataTables.GetDataById(unitToRemove.Data);
                    DataSlot       dataSlot = units.Find((Predicate <DataSlot>)(t => t.Data.GetGlobalID() == _Troop.GetGlobalID()));
                    if (dataSlot != null)
                    {
                        dataSlot.Value = dataSlot.Value - 1;
                    }
                }
                else if (unitToRemove.Data.ToString().StartsWith("260"))
                {
                    SpellData _Spell   = (SpellData)CSVManager.DataTables.GetDataById(unitToRemove.Data);
                    DataSlot  dataSlot = spells.Find((Predicate <DataSlot>)(t => t.Data.GetGlobalID() == _Spell.GetGlobalID()));
                    if (dataSlot != null)
                    {
                        dataSlot.Value = dataSlot.Value - 1;
                    }
                }
            }
        }
コード例 #8
0
 public void AddUsedTroop(CombatItemData cid, int value)
 {
     /*if (State == UserState.PVP)
      * {
      * var info = default(AttackInfo);
      * if (!AttackingInfo.TryGetValue(GetId(), out info))
      * {
      *  Logger.Write("Unable to obtain attack info.");
      * }
      *
      * DataSlot e = info.UsedTroop.Find(t => t.Data.GetGlobalID() == cid.GetGlobalID());
      *  if (e != null)
      *  {
      *      // Troops already exist.
      *      int i = info.UsedTroop.IndexOf(e);
      *      e.Value = e.Value + value;
      *      info.UsedTroop[i] = e;
      *  }
      *  else
      *  {
      *      DataSlot ds = new DataSlot(cid, value);
      *      info.UsedTroop.Add(ds);
      *  }
      * }*/
     //else
     //  Logger.Write("Unsuppored state! AddUsedTroop only for PVP for now.PVE Comming Soon");
 }
コード例 #9
0
ファイル: Avatar.cs プロジェクト: skwbr/UCS-1
        public void SetUnitCount(CombatItemData cd, int count)
        {
            switch (cd.GetCombatItemType())
            {
            case 1:
            {
                var index = GetDataIndex(m_vSpellCount, cd);
                if (index != -1)
                {
                    m_vSpellCount[index].Value = count;
                }
                else
                {
                    var ds = new DataSlot(cd, count);
                    m_vSpellCount.Add(ds);
                }
                break;
            }

            default:
            {
                var index = GetDataIndex(m_vUnitCount, cd);
                if (index != -1)
                {
                    m_vUnitCount[index].Value = count;
                }
                else
                {
                    var ds = new DataSlot(cd, count);
                    m_vUnitCount.Add(ds);
                }
                break;
            }
            }
        }
コード例 #10
0
ファイル: UnitUpgradeComponent.cs プロジェクト: skwbr/UCS-1
        public bool CanStartUpgrading(CombatItemData cid)
        {
            var result = false;

            if (m_vCurrentlyUpgradedUnit == null)
            {
                var b  = (Building)GetParent();
                var ca = GetParent().GetLevel().GetHomeOwnerAvatar();
                var cm = GetParent().GetLevel().GetComponentManager();
                int maxProductionBuildingLevel;
                if (cid.GetCombatItemType() == 1)
                {
                    maxProductionBuildingLevel = cm.GetMaxSpellForgeLevel();
                }
                else
                {
                    maxProductionBuildingLevel = cm.GetMaxBarrackLevel();
                }
                if (ca.GetUnitUpgradeLevel(cid) < cid.GetUpgradeLevelCount() - 1)
                {
                    if (maxProductionBuildingLevel >= cid.GetRequiredProductionHouseLevel() - 1)
                    {
                        result = b.GetUpgradeLevel() >=
                                 cid.GetRequiredLaboratoryLevel(ca.GetUnitUpgradeLevel(cid) + 1) - 1;
                    }
                }
            }
            return(result);
        }
コード例 #11
0
        public override void Execute(Level level)
        {
            List <DataSlot> _PlayerUnits  = level.GetPlayerAvatar().GetUnits();
            List <DataSlot> _PlayerSpells = level.GetPlayerAvatar().GetSpells();

            foreach (UnitToRemove _Unit in UnitsToRemove)
            {
                if (_Unit.Data.ToString().StartsWith("400"))
                {
                    CombatItemData _Troop    = (CombatItemData)CSVManager.DataTables.GetDataById(_Unit.Data);;
                    DataSlot       _DataSlot = _PlayerUnits.Find(t => t.Data.GetGlobalID() == _Troop.GetGlobalID());
                    if (_DataSlot != null)
                    {
                        _DataSlot.Value = _DataSlot.Value - 1;
                    }
                }
                else if (_Unit.Data.ToString().StartsWith("260"))
                {
                    SpellData _Spell    = (SpellData)CSVManager.DataTables.GetDataById(_Unit.Data);;
                    DataSlot  _DataSlot = _PlayerSpells.Find(t => t.Data.GetGlobalID() == _Spell.GetGlobalID());
                    if (_DataSlot != null)
                    {
                        _DataSlot.Value = _DataSlot.Value - 1;
                    }
                }
            }
        }
コード例 #12
0
        public bool CanAddUnit(CombatItemData cd)
        {
            var result = false;

            if (cd != null)
            {
                if (IsSpellForge)
                {
                    result = GetMaxCapacity() >= GetUsedCapacity() + cd.GetHousingSpace();
                }
                else if (IsDarkForge)
                {
                    result = GetMaxCapacity() >= GetUsedCapacity() + cd.GetHousingSpace();
                }
                else
                {
                    var cm           = GetParent().GetLevel().GetComponentManager();
                    var maxCapacity  = cm.GetTotalMaxHousing();  //GetMaxCapacity();
                    var usedCapacity = cm.GetTotalUsedHousing(); //GetUsedCapacity();
                    var housingSpace = cd.GetHousingSpace();
                    if (GetUsedCapacity() < GetMaxCapacity())
                    {
                        result = maxCapacity >= usedCapacity + housingSpace;
                    }
                }
            }
            return(result);
        }
コード例 #13
0
        public void RemoveUnit(CombatItemData cd)
        {
            var index = -1;

            if (GetSlotCount() >= 1)
            {
                for (var i = 0; i < GetSlotCount(); i++)
                {
                    if (m_vUnits[i].Data == cd)
                    {
                        index = i;
                    }
                }
            }
            if (index != -1)
            {
                if (m_vUnits[index].Value >= 1)
                {
                    m_vUnits[index].Value--;
                    if (m_vUnits[index].Value == 0)
                    {
                        m_vUnits.RemoveAt(index);
                        if (GetSlotCount() >= 1)
                        {
                            var ds    = m_vUnits[0];
                            var newcd = (CombatItemData)m_vUnits[0].Data;
                            var ca    = GetParent().GetLevel().GetHomeOwnerAvatar();
                            m_vTimer = new Timer();
                            var trainingTime = newcd.GetTrainingTime(ca.GetUnitUpgradeLevel(newcd));
                            m_vTimer.StartTimer(trainingTime, GetParent().GetLevel().GetTime());
                        }
                    }
                }
            }
        }
コード例 #14
0
        public int GetUnitCount(CombatItemData cd)
        {
            int result = 0;

            if (cd.GetCombatItemType() == 1)
            {
                int index = GetDataIndex(this.m_spellCount, cd);

                if (index != -1)
                {
                    result = m_spellCount[index].Value;
                }
            }

            else
            {
                int index = GetDataIndex(m_vUnitCount, cd);

                if (index != -1)
                {
                    result = m_unitCount[index].Value;
                }
            }

            return(result);
        }
コード例 #15
0
        public int GetTotalRemainingSeconds()
        {
            var result    = 0;
            var firstUnit = true;

            if (m_vUnits.Count > 0)
            {
                foreach (DataSlot ds in m_vUnits)
                {
                    CombatItemData cd = (CombatItemData)ds.Data;
                    if (cd != null)
                    {
                        var count = ds.Value;
                        if (count >= 1)
                        {
                            if (firstUnit)
                            {
                                if (m_vTimer != null)
                                {
                                    result += m_vTimer.GetRemainingSeconds(GetParent().GetLevel().GetTime());
                                }
                                count--;
                                firstUnit = false;
                            }
                            var ca = GetParent().GetLevel().GetHomeOwnerAvatar();
                            result += count * cd.GetTrainingTime(ca.GetUnitUpgradeLevel(cd));
                        }
                    }
                }
            }
            return(result);
        }
コード例 #16
0
        public void SetUnitUpgradeLevel(CombatItemData cd, int level)
        {
            switch (cd.GetCombatItemType())
            {
            case 2:
            {
                int index = GetDataIndex(this.m_heroUpgradeLevel, cd);

                if (index != -1)
                {
                    m_heroUpgradeLevel[index].Value = level;
                }

                else
                {
                    DataSlot ds = new DataSlot(cd, level);
                    m_heroUpgradeLevel.Add(ds);
                }

                break;
            }

            case 1:
            {
                int index = GetDataIndex(this.m_spellUpgradeLevel, cd);

                if (index != -1)
                {
                    m_spellUpgradeLevel[index].Value = level;
                }

                else
                {
                    DataSlot ds = new DataSlot(cd, level);
                    m_spellUpgradeLevel.Add(ds);
                }

                break;
            }

            default:
            {
                int index = GetDataIndex(this.m_unitUpgradeLevel, cd);

                if (index != -1)
                {
                    m_unitUpgradeLevel[index].Value = level;
                }

                else
                {
                    DataSlot ds = new DataSlot(cd, level);
                    m_unitUpgradeLevel.Add(ds);
                }

                break;
            }
            }
        }
コード例 #17
0
 internal override void Decode()
 {
     this.Reader.ReadInt32();
     this.Troop = (CombatItemData)this.Reader.ReadDataReference();
     this.Reader.ReadInt32();
     this.MessageID = this.Reader.ReadInt32();
     this.BuyTroop  = this.Reader.ReadByte();
 }
コード例 #18
0
 public UnitProduction(Level level, CombatItemData cd, bool IsSpellForge)
 {
     m_vUnits        = new List <DataSlot>();
     Unit            = cd;
     m_vTimer        = null;
     m_vLevel        = level;
     m_vIsSpellForge = IsSpellForge;
 }
コード例 #19
0
ファイル: UnitUpgradeComponent.cs プロジェクト: skwbr/UCS-1
 public void StartUpgrading(CombatItemData cid)
 {
     if (CanStartUpgrading(cid))
     {
         m_vCurrentlyUpgradedUnit = cid;
         m_vTimer = new Timer();
         m_vTimer.StartTimer(GetTotalSeconds(), GetParent().GetLevel().GetTime());
     }
 }
コード例 #20
0
 public void StartUpgrading(CombatItemData cid)
 {
     if (CanStartUpgrading(cid))
     {
         m_vCurrentlyUpgradedUnit = cid;
         m_vTimer = new Timer();
         m_vTimer.StartTimer(GetTotalSeconds(), GetParent().Avatar.Avatar.LastTickSaved);
     }
 }
コード例 #21
0
        public CombatItemData GetCurrentlyTrainedUnit()
        {
            CombatItemData cd = null;

            if (m_vUnits.Count >= 1)
            {
                cd = (CombatItemData)m_vUnits[0].Data;
            }
            return(cd);
        }
コード例 #22
0
 public override void Decode()
 {
     using (PacketReader br = new PacketReader(new MemoryStream(GetData())))
     {
         Unknown1  = br.ReadInt32WithEndian();
         Troop     = (CombatItemData)br.ReadDataReference();
         Unknown3  = br.ReadInt32WithEndian();
         MessageID = br.ReadInt32WithEndian();
     }
 }
コード例 #23
0
ファイル: Inventory.cs プロジェクト: SkankinGarbage/mgne
    /// <returns>True if a drop was performed</returns>
    public bool DropItemType(CombatItemData itemData)
    {
        var slot = SlotForItemType(itemData);

        if (slot < 0)
        {
            return(false);
        }
        Drop(slot);
        return(true);
    }
コード例 #24
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        CombatItemData combatItem = (CombatItemData)target;

        if (!serializedObject.FindProperty("warhead").hasMultipleDifferentValues)
        {
            combatItem.warhead = warheadUtil.DrawSelector(combatItem.warhead);
        }
    }
コード例 #25
0
ファイル: UnitUpgradeComponent.cs プロジェクト: skwbr/UCS-1
 public void FinishUpgrading()
 {
     if (m_vCurrentlyUpgradedUnit != null)
     {
         var ca    = GetParent().GetLevel().GetHomeOwnerAvatar();
         var level = ca.GetUnitUpgradeLevel(m_vCurrentlyUpgradedUnit);
         ca.SetUnitUpgradeLevel(m_vCurrentlyUpgradedUnit, level + 1);
     }
     m_vTimer = null;
     m_vCurrentlyUpgradedUnit = null;
 }
コード例 #26
0
ファイル: UnitStorageComponent.cs プロジェクト: Dekryptor/UCS
        public int GetUnitCountByData(CombatItemData cd)
        {
            var count = 0;

            for (var i = 0; i < m_vUnits.Count; i++)
            {
                if (m_vUnits[i].UnitData == cd)
                {
                    count += m_vUnits[i].Count;
                }
            }
            return(count);
        }
コード例 #27
0
        public override void Execute(Level level)
        {
            ClientAvatar avatar = level.GetPlayerAvatar();

            if (UnitType.ToString().StartsWith("400"))
            {
                CombatItemData  _TroopData       = (CombatItemData)CSVManager.DataTables.GetDataById(UnitType);
                List <DataSlot> units            = level.GetPlayerAvatar().GetUnits();
                ResourceData    trainingResource = _TroopData.GetTrainingResource();
                if (_TroopData == null)
                {
                    return;
                }
                DataSlot dataSlot1 = units.Find((Predicate <DataSlot>)(t => t.Data.GetGlobalID() == _TroopData.GetGlobalID()));
                if (dataSlot1 != null)
                {
                    dataSlot1.Value = dataSlot1.Value + Count;
                }
                else
                {
                    DataSlot dataSlot2 = new DataSlot((Data)_TroopData, Count);
                    units.Add(dataSlot2);
                }
                avatar.SetResourceCount(trainingResource, avatar.GetResourceCount(trainingResource) - _TroopData.GetTrainingCost(avatar.GetUnitUpgradeLevel(_TroopData)));
            }
            else
            {
                if (!this.UnitType.ToString().StartsWith("260"))
                {
                    return;
                }
                SpellData       _SpellData       = (SpellData)CSVManager.DataTables.GetDataById(UnitType);
                List <DataSlot> spells           = level.GetPlayerAvatar().GetSpells();
                ResourceData    trainingResource = _SpellData.GetTrainingResource();
                if (_SpellData == null)
                {
                    return;
                }
                DataSlot dataSlot1 = spells.Find((Predicate <DataSlot>)(t => t.Data.GetGlobalID() == _SpellData.GetGlobalID()));
                if (dataSlot1 != null)
                {
                    dataSlot1.Value = dataSlot1.Value + Count;
                }
                else
                {
                    DataSlot dataSlot2 = new DataSlot((Data)_SpellData, Count);
                    spells.Add(dataSlot2);
                }
                avatar.SetResourceCount(trainingResource, avatar.GetResourceCount(trainingResource) - _SpellData.GetTrainingCost(avatar.GetUnitUpgradeLevel((CombatItemData)_SpellData)));
            }
        }
コード例 #28
0
ファイル: UnitStorageComponent.cs プロジェクト: Dekryptor/UCS
        public int GetUnitTypeIndex(CombatItemData cd)
        {
            var index = -1;

            for (var i = 0; i < m_vUnits.Count; i++)
            {
                if (m_vUnits[i].UnitData == cd)
                {
                    index = i;
                    break;
                }
            }
            return(index);
        }
コード例 #29
0
ファイル: UnitUpgradeComponent.cs プロジェクト: skwbr/UCS-1
        public override void Load(JObject jsonObject)
        {
            var unitUpgradeObject = (JObject)jsonObject["unit_upg"];

            if (unitUpgradeObject != null)
            {
                m_vTimer = new Timer();
                var remainingTime = unitUpgradeObject["t"].ToObject <int>();
                m_vTimer.StartTimer(remainingTime, GetParent().GetLevel().GetTime());

                var id = unitUpgradeObject["id"].ToObject <int>();
                m_vCurrentlyUpgradedUnit = (CombatItemData)ObjectManager.DataTables.GetDataById(id);
            }
        }
コード例 #30
0
ファイル: TrainUnitCommand.cs プロジェクト: 0trebor0/UCSMagic
        internal override void Process()
        {
            ClientAvatar _Player = this.Device.Player.Avatar;

            if (UnitType.ToString().StartsWith("400"))
            {
                CombatItemData  _TroopData        = (CombatItemData)CSVManager.DataTables.GetDataById(UnitType);
                List <DataSlot> _PlayerUnits      = this.Device.Player.Avatar.GetUnits();
                ResourceData    _TrainingResource = _TroopData.GetTrainingResource();

                if (_TroopData != null)
                {
                    DataSlot _DataSlot = _PlayerUnits.Find(t => t.Data.GetGlobalID() == _TroopData.GetGlobalID());
                    if (_DataSlot != null)
                    {
                        _DataSlot.Value = _DataSlot.Value + this.Count;
                    }
                    else
                    {
                        DataSlot ds = new DataSlot(_TroopData, this.Count);
                        _PlayerUnits.Add(ds);
                    }

                    _Player.SetResourceCount(_TrainingResource, _Player.GetResourceCount(_TrainingResource) - _TroopData.GetTrainingCost(_Player.GetUnitUpgradeLevel(_TroopData)));
                }
            }
            else if (UnitType.ToString().StartsWith("260"))
            {
                SpellData       _SpellData    = (SpellData)CSVManager.DataTables.GetDataById(UnitType);
                List <DataSlot> _PlayerSpells = this.Device.Player.Avatar.GetSpells();
                ResourceData    _CastResource = _SpellData.GetTrainingResource();

                if (_SpellData != null)
                {
                    DataSlot _DataSlot = _PlayerSpells.Find(t => t.Data.GetGlobalID() == _SpellData.GetGlobalID());
                    if (_DataSlot != null)
                    {
                        _DataSlot.Value = _DataSlot.Value + this.Count;
                    }
                    else
                    {
                        DataSlot ds = new DataSlot(_SpellData, this.Count);
                        _PlayerSpells.Add(ds);
                    }

                    _Player.SetResourceCount(_CastResource, _Player.GetResourceCount(_CastResource) - _SpellData.GetTrainingCost(_Player.GetUnitUpgradeLevel(_SpellData)));
                }
            }
        }