示例#1
0
        public override BaseContract Generate(Race race, int level, string sourceWorld, ContractManager manager, IContractResource resource)
        {
            var contracts = resource.contracts.GetContracts(ContractCategory.destroyConstruction, level);

            if (contracts.Count == 0)
            {
                s_Log.InfoFormat("contracts of type destroyConstruction is zero");
                return(null);
            }
            DestroyConstructionContractData data = contracts.AnyElement() as DestroyConstructionContractData;

            if (data == null)
            {
                s_Log.InfoFormat("contract data is zero");
                return(null);
            }

            var sourceRaceableComponent = manager.GetComponent <RaceableObject>();

            if (sourceRaceableComponent == null)
            {
                s_Log.InfoFormat("not found raceable component on player");
                return(null);
            }


            Race           sourceRace       = (Race)sourceRaceableComponent.race;
            BotItemSubType constructionType = data.GenerateConstructionType();
            Race           constructionRace = data.GenerateTargetRace(sourceRace);

            DestroyConstructionContract result = new DestroyConstructionContract(data.id, 0, sourceWorld, manager, constructionType, constructionRace);

            s_Log.InfoFormat("successfully generated contract destroy = {0} of race = {1}", constructionType, constructionRace);
            return(result);
        }
示例#2
0
        //private ReaderWriterLockSlim lockSlim;

        /// <summary>
        /// Get bot items of selected sub type and and filter
        /// </summary>
        /// <param name="subType"></param>
        /// <param name="filter"></param>
        /// <returns></returns>
        public Dictionary <string, Item> GetBotItems(BotItemSubType subType, Func <Item, bool> filter)
        {
            var concurrentDict = GetBotItemsConcurrent(subType, filter);
            Dictionary <string, Item> result = new Dictionary <string, Item>();

            foreach (var pair in concurrentDict)
            {
                result.Add(pair.Key, pair.Value);
            }
            return(result);
        }
示例#3
0
        public ConcurrentDictionary <string, Item> GetBotItemsConcurrent(BotItemSubType subType, Func <Item, bool> filter)
        {
            var items = ItemCache.GetItems((byte)ItemType.Bot);

            ConcurrentDictionary <string, Item> result = new ConcurrentDictionary <string, Item>();

            foreach (var p in items)
            {
                var bot = p.Value.GetComponent <BotObject>();
                if (bot.botSubType == (byte)subType)
                {
                    if (filter(p.Value))
                    {
                        result.TryAdd(p.Value.Id, p.Value);
                    }
                }
            }
            return(result);
        }
示例#4
0
        private void LogObject(NebulaObject obj)
        {
            var bot = obj.GetComponent <BotObject>();

            if (bot != null)
            {
                BotItemSubType subType = (BotItemSubType)bot.botSubType;
                if (subType == BotItemSubType.Turret)
                {
                    log.InfoFormat("turret in world = {0} respawned [purple]", mWorld.Name);
                }
                else if (subType == BotItemSubType.Outpost)
                {
                    log.InfoFormat("fortification in world = {0} respawned [purple]", mWorld.Name);
                }
                else if (subType == BotItemSubType.MainOutpost)
                {
                    log.InfoFormat("outpost in world = {0} respawned [purple]", mWorld.Name);
                }
            }
        }
示例#5
0
        private float ComputeMissProb(NebulaObject targetObject)
        {
            //if target either planet obj or turret or drill we don't use level difference miss
            if (targetObject.Type == (byte)ItemType.Bot)
            {
                var botComp = targetObject.GetComponent <BotObject>();
                if (botComp != null)
                {
                    BotItemSubType subType = (BotItemSubType)botComp.botSubType;
                    switch (subType)
                    {
                    case BotItemSubType.PlanetBuilding:
                    case BotItemSubType.Turret:
                    case BotItemSubType.Drill:
                        if (nebulaObject.Type == (byte)ItemType.Avatar)
                        {
                            log.InfoFormat("your attacked {0}, miss prob %", subType);
                        }
                        return(0);
                    }
                }
            }

            //if source planet obj or drill or turret we don't use level difference miss
            if (nebulaObject.Type == (byte)ItemType.Bot)
            {
                if (m_CachedBot != null)
                {
                    BotItemSubType subType = (BotItemSubType)m_CachedBot.botSubType;
                    switch (subType)
                    {
                    case BotItemSubType.Drill:
                    case BotItemSubType.PlanetBuilding:
                    case BotItemSubType.Turret:
                        return(0);
                    }
                }
            }

            var targetCharacter = targetObject.Character();

            if (!targetCharacter)
            {
                return(0f);
            }

            int myLevel     = cachedCharacter.level;
            int targetLevel = targetCharacter.level;
            int diff        = myLevel - targetLevel;

            if (diff >= 0)
            {
                return(0f);
            }
            switch (Mathf.Abs(diff))
            {
            case 1:
                return(0.01f);

            case 2:
                return(0.05f);

            case 3:
                return(0.15f);

            case 4:
                return(0.25f);

            case 5:
                return(0.4f);
            }

            return(0.6f);
        }
示例#6
0
 public BotComponentData(BotItemSubType subType)
 {
     this.subType = subType;
     botGroup     = string.Empty;
 }
示例#7
0
 public BotComponentData(Hashtable hash)
 {
     subType = (BotItemSubType)(byte)hash.GetValue <int>((int)SPC.SubType, (int)BotItemSubType.None);
 }
示例#8
0
 public BotComponentData(BotItemSubType subType)
 {
     this.subType = subType;
 }
示例#9
0
 public BotComponentData(XElement e)
 {
     subType = (BotItemSubType)Enum.Parse(typeof(BotItemSubType), e.GetString("bot_sub_type"));
 }
示例#10
0
 public void SetSubType(BotItemSubType subType)
 {
     SetSubType((byte)subType);
 }
 private void FromHash(Hashtable hash)
 {
     m_ConstructionType = (BotItemSubType)(byte)hash.GetValue <int>((int)SPC.SubType, (int)BotItemSubType.Turret);
     m_ConstructionRace = (Race)(byte)hash.GetValue <int>((int)SPC.Race, (int)Race.Borguzands);
 }
 public DestroyConstructionContract(string id, int stage, string sourceWorld, ContractManager mgr, BotItemSubType constrType, Race constrRace)
     : base(id, stage, sourceWorld, ContractCategory.destroyConstruction, mgr)
 {
     m_ConstructionType = constrType;
     m_ConstructionRace = constrRace;
 }