示例#1
0
        public void RemoveUnit(CombatItemData cd)
        {
            int index = -1;

            if (GetSlotCount() >= 1)
            {
                for (int 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)
                        {
                            DataSlot       ds    = m_vUnits[0];
                            CombatItemData newcd = (CombatItemData)m_vUnits[0].Data;
                            ClientAvatar   ca    = GetParent().GetLevel().GetHomeOwnerAvatar();
                            m_vTimer = new Timer();
                            int trainingTime = newcd.GetTrainingTime(ca.GetUnitUpgradeLevel(newcd));
                            m_vTimer.StartTimer(trainingTime, GetParent().GetLevel().GetTime());
                        }
                    }
                }
            }
        }
示例#2
0
 public void SetAvatar(ClientAvatar avatar)
 {
     this.m_vSenderId       = avatar.GetId();
     this.m_vSenderName     = avatar.GetAvatarName();
     this.m_vSenderLevel    = avatar.GetAvatarLevel();
     this.m_vSenderLeagueId = avatar.GetLeagueId();
 }
 public void SetAvatar(ClientAvatar avatar)
 {
     m_vSenderId = avatar.GetId();
     m_vSenderName = avatar.GetAvatarName();
     m_vSenderLevel = avatar.GetAvatarLevel();
     m_vSenderLeagueId = avatar.GetLeagueId();
 }
示例#4
0
        public bool CanStartUpgrading(CombatItemData cid)
        {
            bool result = false;

            if (m_vCurrentlyUpgradedUnit == null)
            {
                Building         b  = (Building)GetParent();
                ClientAvatar     ca = GetParent().GetLevel().GetHomeOwnerAvatar();
                ComponentManager 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);
        }
示例#5
0
        private DateTime m_vTime; // a1 + 40

        public Level()
        {
            this.GameObjectManager    = new GameObjectManager(this);
            this.m_vClientAvatar      = new ClientAvatar();
            this.m_vAccountPrivileges = 0;
            this.m_vAccountStatus     = 0;
        }
示例#6
0
        public int GetTotalRemainingSeconds()
        {
            int  result    = 0;
            bool firstUnit = true;

            if (m_vUnits.Count > 0)
            {
                foreach (var ds in m_vUnits)
                {
                    CombatItemData cd = (CombatItemData)ds.Data;
                    if (cd != null)
                    {
                        int count = ds.Value;
                        if (count >= 1)
                        {
                            if (firstUnit)
                            {
                                if (m_vTimer != null)
                                {
                                    result += m_vTimer.GetRemainingSeconds(GetParent().GetLevel().GetTime());
                                }
                                count--;
                                firstUnit = false;
                            }
                            ClientAvatar ca = GetParent().GetLevel().GetHomeOwnerAvatar();
                            result += count * cd.GetTrainingTime(ca.GetUnitUpgradeLevel(cd));
                        }
                    }
                }
            }
            return(result);
        }
示例#7
0
        //MissionManager
        //AchievementManager
        //CooldownManager

        public Level()
        {
            WorkerManager        = new WorkerManager();
            GameObjectManager    = new GameObjectManager(this);
            m_vClientAvatar      = new ClientAvatar();
            m_vAccountPrivileges = 0;
            m_vAccountStatus     = 0;
        }
示例#8
0
 public Level(long id)
 {
     this.GameObjectManager    = new GameObjectManager(this);
     this.m_vClientAvatar      = new ClientAvatar(id);
     this.m_vTime              = DateTime.UtcNow;
     this.m_vAccountPrivileges = 0;
     this.m_vAccountStatus     = 0;
 }
示例#9
0
        public bool IsMaxLevel()
        {
            ClientAvatar ca           = GetParent().GetLevel().GetPlayerAvatar();
            int          currentLevel = ca.GetUnitUpgradeLevel(m_vHeroData);
            int          maxLevel     = m_vHeroData.GetUpgradeLevelCount() - 1;

            return(currentLevel >= maxLevel);
        }
示例#10
0
 public void SetAvatar(ClientAvatar avatar)
 {
     this.m_vSenderId    = avatar.GetId();
     this.m_vHomeId      = avatar.GetId();
     this.m_vSenderName  = avatar.GetAvatarName();
     this.m_vSenderLevel = avatar.GetAvatarLevel();
     this.m_vSenderRole  = avatar.GetAllianceRole();
 }
示例#11
0
        //MissionManager
        //AchievementManager
        //CooldownManager

        public Level()
        {
            WorkerManager = new WorkerManager();
            GameObjectManager = new GameObjectManager(this);
            m_vClientAvatar = new ClientAvatar();
            m_vAccountPrivileges = 0;
            m_vAccountStatus = 0;
        }
示例#12
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="Battle" /> class.
        /// </summary>
        /// <param name="Battle">The battle.</param>
        /// <param name="_Attacker">The attacker.</param>
        /// <param name="_Enemy">The enemy.</param>
        internal Battle(long Battle, Level _Attacker, Level _Enemy, bool clone = true)
        {
            this.Battle_ID = Battle;

            this.Attacker       = _Attacker.Avatar;
            this.Defender       = _Enemy.Avatar;
            this.Base           = _Enemy.GameObjectManager.Save();
            this.Attacker.Units = new Units();
        }
示例#13
0
 public Level(long id)
 {
     WorkerManager = new WorkerManager();
     GameObjectManager = new GameObjectManager(this);
     m_vClientAvatar = new ClientAvatar(id);
     m_vTime = DateTime.UtcNow;
     m_vAccountPrivileges = 0;
     m_vAccountStatus = 0;
 }
示例#14
0
 public void SetAvatar(ClientAvatar avatar)
 {
     m_vSenderId       = avatar.GetId();
     m_vHomeId         = avatar.GetId();
     m_vSenderName     = avatar.GetAvatarName();
     m_vSenderLeagueId = avatar.GetLeagueId();
     m_vSenderLevel    = avatar.GetAvatarLevel();
     m_vSenderRole     = 1;
 }
示例#15
0
 public Level(long id)
 {
     WorkerManager        = new WorkerManager();
     GameObjectManager    = new GameObjectManager(this);
     m_vClientAvatar      = new ClientAvatar(id);
     m_vTime              = DateTime.UtcNow;
     m_vAccountPrivileges = 0;
     m_vAccountStatus     = 0;
 }
示例#16
0
 public Level(long id, string token)
 {
     WorkerManager        = new WorkerManager();
     GameObjectManager    = new GameObjectManager(this);
     m_vClientAvatar      = new ClientAvatar(id, token);
     m_vTime              = DateTime.UtcNow;
     m_vAccountPrivileges = 0;
     m_vAccountStatus     = 0;
     m_vIPAddress         = "0.0.0.0";
 }
示例#17
0
 public void FinishUpgrading()
 {
     if (m_vCurrentlyUpgradedUnit != null)
     {
         ClientAvatar ca    = GetParent().GetLevel().GetHomeOwnerAvatar();
         int          level = ca.GetUnitUpgradeLevel(m_vCurrentlyUpgradedUnit);
         ca.SetUnitUpgradeLevel(m_vCurrentlyUpgradedUnit, level + 1);
     }
     m_vTimer = null;
     m_vCurrentlyUpgradedUnit = null;
 }
示例#18
0
        public void FinishUpgrading()
        {
            ClientAvatar ca           = GetParent().GetLevel().GetPlayerAvatar();
            int          currentLevel = ca.GetUnitUpgradeLevel(m_vHeroData);

            ca.SetUnitUpgradeLevel(m_vHeroData, currentLevel + 1);
            //(*(*v3 + 160))(v3, 1, *(v1 + 16), 1);
            GetParent().GetLevel().WorkerManager.DeallocateWorker(GetParent());
            //SetHeroState (*(*v3 + 224))(v3, *(v1 + 16), 3);
            m_vTimer = null;
        }
示例#19
0
        public int GetTotalSeconds()
        {
            int result = 0;

            if (m_vCurrentlyUpgradedUnit != null)
            {
                ClientAvatar ca    = GetParent().GetLevel().GetHomeOwnerAvatar();
                int          level = ca.GetUnitUpgradeLevel(m_vCurrentlyUpgradedUnit);
                result = m_vCurrentlyUpgradedUnit.GetUpgradeTime(level);
            }
            return(result);
        }
示例#20
0
 public void SpeedUpConstruction()
 {
     if (IsConstructing())
     {
         ClientAvatar ca = Avatar.Avatar;
         int          remainingSeconds = m_vTimer.GetRemainingSeconds(m_vLevel.Avatar.LastTickSaved);
         int          cost             = GamePlayUtil.GetSpeedUpCost(remainingSeconds);
         if (ca.HasEnoughDiamonds(cost))
         {
             ca.UseDiamonds(cost);
             FinishConstruction();
         }
     }
 }
示例#21
0
 public void AddUnitImpl(CombatItemData cd, int level)
 {
     if (CanAddUnit(cd))
     {
         int unitIndex = GetUnitTypeIndex(cd, level);
         if (unitIndex == -1)
         {
             UnitSlot us = new UnitSlot(cd, level, 1);
             m_vUnits.Add(us);
         }
         else
         {
             m_vUnits[unitIndex].Count++;
         }
         ClientAvatar ca        = GetParent().GetLevel().GetPlayerAvatar();
         int          unitCount = ca.GetUnitCount(cd);
         ca.SetUnitCount(cd, unitCount + 1);
     }
 }
示例#22
0
        public void CollectResources()
        {
            ConstructionItem ci               = (ConstructionItem)GetParent();
            TimeSpan         span             = ci.GetLevel().GetTime() - this.m_vTimeSinceLastClick;
            float            currentResources = ((this.m_vResourcesPerHour[ci.UpgradeLevel] / (60f * 60f)) * (float)(span.TotalSeconds));

            currentResources = Math.Min(Math.Max(currentResources, 0), this.m_vMaxResources[ci.UpgradeLevel]);

            if (currentResources >= 1)
            {
                ClientAvatar ca = ci.GetLevel().GetPlayerAvatar();
                if (ca.GetResourceCap(this.m_vProductionResourceData) >= ca.GetResourceCount(this.m_vProductionResourceData) + currentResources)
                {
                    Debugger.WriteLine(String.Format("Collect {0} {1}", (int)currentResources, this.m_vProductionResourceData.GetName()), null, 5, ConsoleColor.Green);

                    ca.CommodityCountChangeHelper(0, this.m_vProductionResourceData, (int)currentResources);
                    this.m_vTimeSinceLastClick = ci.GetLevel().GetTime();
                }
            }
        }
示例#23
0
 public void AddUnitToProductionQueue(CombatItemData cd)
 {
     if (CanAddUnitToQueue(cd))
     {
         for (int i = 0; i < GetSlotCount(); i++)
         {
             if ((CombatItemData)m_vUnits[i].Data == cd)
             {
                 m_vUnits[i].Value++;
                 return;
             }
         }
         DataSlot ds = new DataSlot(cd, 1);
         m_vUnits.Add(ds);
         if (m_vTimer == null)
         {
             ClientAvatar ca = GetParent().GetLevel().GetHomeOwnerAvatar();
             m_vTimer = new Timer();
             int trainingTime = cd.GetTrainingTime(ca.GetUnitUpgradeLevel(cd));
             m_vTimer.StartTimer(trainingTime, GetParent().GetLevel().GetTime());
         }
     }
 }
示例#24
0
        public void RemoveUnitsImpl(CombatItemData cd, int level, int count)
        {
            int unitIndex = GetUnitTypeIndex(cd, level);

            if (unitIndex == -1)
            {
                //Do nothing, should be empty yet
            }
            else
            {
                UnitSlot us = m_vUnits[unitIndex];
                if (us.Count <= count)
                {
                    m_vUnits.Remove(us);
                }
                else
                {
                    us.Count -= count;
                }
                ClientAvatar ca        = GetParent().GetLevel().GetPlayerAvatar();
                int          unitCount = ca.GetUnitCount(cd);
                ca.SetUnitCount(cd, unitCount - count);
            }
        }
示例#25
0
        public void AddUnitToProductionQueue(CombatItemData cd)
        {
            if (!CanAddUnitToQueue(cd))
            {
                return;
            }
            for (int index = 0; index < GetSlotCount(); ++index)
            {
                if ((CombatItemData)m_vUnits[index].Data == cd)
                {
                    ++m_vUnits[index].Value;
                    return;
                }
            }
            m_vUnits.Add(new DataSlot((Data)cd, 1));
            if (m_vTimer != null)
            {
                return;
            }
            ClientAvatar avatar = GetParent().GetLevel().GetHomeOwnerAvatar();

            m_vTimer = new Timer();
            m_vTimer.StartTimer(cd.GetTrainingTime(avatar.GetUnitUpgradeLevel(cd)), GetParent().GetLevel().GetTime());
        }
示例#26
0
 public Level()
 {
     this.WorkerManager     = new WorkerManager();
     this.GameObjectManager = new GameObjectManager(this);
     this.Avatar            = new ClientAvatar();
 }
示例#27
0
 public Level(long id, string token)
 {
     this.WorkerManager     = new WorkerManager();
     this.GameObjectManager = new GameObjectManager(this);
     this.Avatar            = new ClientAvatar(id, token);
 }