示例#1
0
 public void Release(ListUpgrade type, VFXArcher obj)
 {
     if (pooling.ContainsKey(type))
     {
         pooling[type].Release(obj);
     }
 }
示例#2
0
    private void OnBtnElement(ListUpgrade type)
    {
        SQLiteTable_MainBase table = Singleton.Instance <DBReference>()[type] as SQLiteTable_MainBase;

        if (table == null)
        {
            return;
        }

        int[]       need;
        MainBaseRow row = table.Rows.FirstOrDefault(x => x.Level == SyncData.CurrentBaseUpgrade[type].Level);

        if (row != null)
        {
            need = new int[] { row.FoodCost, row.WoodCost, row.StoneCost, row.MetalCost }
        }
        ;
        else
        {
            need = new int[4];
        }

        Group[WindowType.UpgradeResearch].Load(
            type,
            need,
            row?.MightBonus,
            row?.TimeMin,
            row?.TimeInt
            );
    }
示例#3
0
    public override void Load(params object[] input)
    {
        BaseInfoRow baseInfo = SyncData.CurrentMainBase;

        ListUpgrade tranningType = baseInfo.TrainingUnit_ID;

        if (tranningType.IsDefined())
        {
            ITable table = dBReference[tranningType];
            int    level = SyncData.CurrentBaseUpgrade[tranningType].Level;

            ITableData typeInfo = table[level - 1];

            TranningProgress.Slider.MaxValue =
                fieldReflection.GetPublicField <int>(typeInfo, "TrainingTime") * baseInfo.TrainingQuality;

            AcceptBtn.Interactable = false;
            TranningProgress.gameObject.SetActive(true);
        }
        else
        {
            AcceptBtn.Interactable = true;
            TranningProgress.gameObject.SetActive(false);
        }
    }
示例#4
0
        private void TrainingDone(Sync sync)
        {
            UserInfoRow          user       = sync.MainUser;
            JSONTable_BaseDefend baseDefend = sync.CurrentBaseDefend;
            BaseDefendRow        defendRow  = baseDefend.ReadOnlyRows.FirstOrDefault(r => r.ID_Unit == TrainingUnit_ID);

            if (defendRow == null)
            {
                baseDefend.Insert(new BaseDefendRow()
                {
                    BaseNumber = BaseNumber,
                    ID_Unit    = TrainingUnit_ID,
                    Quality    = TrainingQuality,
                });
            }
            else
            {
                defendRow.Quality += TrainingQuality;
            }

            user.Might     += Training_Might;
            TrainingUnit_ID = 0;
            TrainingQuality = 0;
            Training_Might  = 0;
        }
示例#5
0
    public override void Load(params object[] data)
    {
        ElementTypeInfo armyType = ArmyTypes[Toggle.ActiveIndex];
        ListUpgrade     type     = armyType.BaseType;

        // sv data
        int mainbaseLv = SyncData.CurrentBaseUpgrade[ListUpgrade.MainBase].Level;
        int selTypeLv  = SyncData.CurrentBaseUpgrade[type].Level;

        for (int i = 0, level = 0; i < armyType.Types.Length; i++)
        {
            level = SyncData.CurrentBaseUpgrade[armyType.Types[i]].Level;
            elements[i].Icon.InteractableChange(level > 0);
            elements[i].LevelBar.Value = level;
            elements[i].LevelBar.SetDefaultPlaceholder();
        }

        // check active or not for upgrade btn
        upgradeBtn.InteractableChange(mainbaseLv > selTypeLv);

        // set level bar value and rename element btn
        levelBar.Value = selTypeLv;
        levelBar.SetDefaultPlaceholder();
        for (int i = 0; i < armyType.Types.Length; i++)
        {
            elements[i].Icon.Placeholder.text = armyType.Titles[i];
        }
    }
示例#6
0
 public TrainingCostRow this[ListUpgrade type]
 {
     get
     {
         return(Rows.FirstOrDefault(r => r.ID_Unit == type));
     }
 }
示例#7
0
    private AgentRemote CreatePoolingItem(int id, ListUpgrade type)
    {
        AgentRemote remote = Create(type);

        remote?.FirstSetup(id);
        return(remote);
    }
示例#8
0
 public ITable this[ListUpgrade dbType]
 {
     get
     {
         try { return(dbs[dbType]); }
         catch { return(null); }
     }
 }
示例#9
0
 private AgentRemote Create(ListUpgrade type)
 {
     AgentPrefabs.TryGetValue(type.GetHashCode(), out AgentRemote res);
     if (res == null)
     {
         return(null);
     }
     return(Instantiate(res, Container));
 }
示例#10
0
    private void OnUpgradeBtn()
    {
        ElementTypeInfo armyType = ArmyTypes[Toggle.ActiveIndex];
        ListUpgrade     type     = armyType.BaseType;

        // open
        Group.Open(WindowType.UpgradeResearch);
        Group[WindowType.UpgradeResearch].Load(type);
    }
示例#11
0
        private void ResearchDone(Sync sync)
        {
            UserInfoRow           user        = sync.MainUser;
            JSONTable_BaseUpgrade baseUpgrade = sync.CurrentBaseUpgrade;

            baseUpgrade[ResearchWait_ID].Level++;
            user.Might     += ResearchWait_Might;
            ResearchWait_ID = 0;
        }
示例#12
0
    private void CreateType(ListUpgrade type, int maxQuality)
    {
        DeployMilitaryTag tag = GetTag();

        tag.Icon.Placeholder.text = type.ToString();
        tag.MaxQuality            = maxQuality;
        tag.Type = type;
        tag.gameObject.SetActive(true);
    }
示例#13
0
 public VFXArcher GetItem(ListUpgrade type)
 {
     if (pooling.ContainsKey(type))
     {
         Debugger.Log("get vfx " + type);
         return(pooling[type].GetItem());
     }
     Debugger.Log("type not found");
     return(null);
 }
示例#14
0
        private void UpgradeDone(Sync sync)
        {
            UserInfoRow           user        = sync.MainUser;
            JSONTable_BaseUpgrade baseUpgrade = sync.CurrentBaseUpgrade;

            baseUpgrade[UpgradeWait_ID].Level++;
            user.Might += UpgradeWait_Might;

            UpgradeWait_ID = 0;
        }
示例#15
0
 public AgentRemote GetItem(ListUpgrade type)
 {
     if (AgentPools.TryGetValue(type.GetHashCode(), out Pooling <AgentRemote> pool))
     {
         return(pool.GetItem());
     }
     else
     {
         return(CreatePool(type).GetItem());
     }
 }
示例#16
0
    private void DecreaseQuality()
    {
        JSONTable_BaseDefend baseDefend = SyncData.CurrentBaseDefend;

        ListUpgrade unitType = refTag.Type;
        int         quality  = (int)refTag.Slider.Value;

        BaseDefendRow baseDefendRow = baseDefend.ReadOnlyRows.FirstOrDefault(r => r.ID_Unit == unitType);

        baseDefendRow.Quality -= quality;
    }
示例#17
0
 public void Release(ListUpgrade type, AgentRemote agent)
 {
     if (AgentPools.TryGetValue(type.GetHashCode(), out Pooling <AgentRemote> pool))
     {
         pool.Release(agent);
     }
     else
     {
         CreatePool(type).Release(agent);
     }
 }
示例#18
0
    private Pooling <AgentRemote> CreatePool(ListUpgrade type)
    {
        int hashCode = type.GetHashCode();

        AgentPools[hashCode] = new Pooling <AgentRemote>(
            delegate(int insId)
        {
            return(CreatePoolingItem(insId, type));
        });

        return(AgentPools[hashCode]);
    }
示例#19
0
        private int GetResearchMaxTime()
        {
            ListUpgrade type = baseInfo.ResearchWait_ID;

            if (type.IsDefined())
            {
                int        level = SyncData.CurrentBaseUpgrade[type].Level;
                ITableData data  = dbRef[type][level - 1];
                return(fieldReflection.GetPublicField <int>(data, "TimeInt"));
            }
            return(0);
        }
示例#20
0
        private int GetTraingMaxTime()
        {
            ListUpgrade type = baseInfo.TrainingUnit_ID;

            if (type.IsDefined())
            {
                int        level        = SyncData.CurrentBaseUpgrade[type].Level;
                ITableData data         = dbRef[type][level - 1];
                int        trainingTime = fieldReflection.GetFieldValue <int>(data, "TrainingTime", BindingFlags.Public | BindingFlags.Instance);
                return(trainingTime * baseInfo.TrainingQuality);
            }
            return(0);
        }
示例#21
0
    private void OnSelected(ListUpgrade type)
    {
        selectedType = type;
        refType      = SyncData.CurrentBaseUpgrade[type];
        ITable dbTable = dBReference[selectedType];

        SQLiteTable_TrainningCost costTable = dBReference[DBType.TrainningCost] as SQLiteTable_TrainningCost;


        refTypeTraining = dbTable[SyncData.CurrentBaseUpgrade[selectedType].Level - 1];
        refCostInfo     = costTable[selectedType];

        CurrentSelect.Placeholder.text = selectedType.ToString().InsertSpace();
    }
示例#22
0
        private bool ValidateResearchTask(MiniTaskWDOElement taskElement)
        {
            ListUpgrade type = baseInfo.ResearchWait_ID;

            if (type.IsDefined())
            {
                taskElement.SetGetTimeFunc
                (
                    delegate { return(GetResearchTimeString(taskElement)); },
                    GetResearchMaxTime()
                );
                taskElement.SetTitleFunc(delegate { return("Researching " + type.ToString().InsertSpace() + "..."); });
                taskElement.SetSliderValue(GetResearchTime);
                taskElement.gameObject.SetActive(true);
                return(true);
            }
            return(false);
        }
示例#23
0
    /// <summary>
    /// 0: type - ListUpgrade
    /// 1: need material - int[4]
    /// 2: might bonus - int
    /// 3: time min - string
    /// 4: time int - int
    /// </summary>
    /// <param name="data">Params object</param>
    public override void Load(params object[] data)
    {
        currentMainBase = SyncData.CurrentMainBase;

        ListUpgrade loadType = data.TryGet <ListUpgrade>(0);
        ITable      table    = dbReference[loadType];

        string title = loadType.ToString().InsertSpace();
        int    level = SyncData.CurrentBaseUpgrade[loadType].Level;


        ITableData needInfo = table[level - 1];

        int foodCost   = GetPublicValue <int>(needInfo, "FoodCost");
        int woodCost   = GetPublicValue <int>(needInfo, "WoodCost");
        int metalCost  = GetPublicValue <int>(needInfo, "MetalCost");
        int stoneCost  = GetPublicValue <int>(needInfo, "StoneCost");
        int mightBonus = GetPublicValue <int>(needInfo, "MightBonus");

        int[] needMaterials = new int[] {
            foodCost,
            woodCost,
            stoneCost,
            metalCost
        };

        curMaterials[0] = currentMainBase.Farm;
        curMaterials[1] = currentMainBase.Wood;
        curMaterials[2] = currentMainBase.Stone;
        curMaterials[3] = currentMainBase.Metal;

        isUpgradeType = loadType.IsUpgrade();

        bool activeProgressBar = isUpgradeType ? currentMainBase.UpgradeWait_ID.IsDefined()
                                                            : currentMainBase.ResearchWait_ID.IsDefined();

        bool activeBtnGroup = !activeProgressBar;

        activeBtnGroup = activeBtnGroup && IsEnoughtMeterial(needMaterials);
        ActiveBtnGroup(activeBtnGroup);


        bool isSimilarCurUpgResType = true;

        if (isUpgradeType)
        {
            if (currentMainBase.UpgradeWait_ID.IsDefined() &&
                loadType != currentMainBase.UpgradeWait_ID)
            {
                loadType = currentMainBase.UpgradeWait_ID;
                isSimilarCurUpgResType = false;
            }
        }
        else
        {
            if (currentMainBase.ResearchWait_ID.IsDefined() &&
                loadType != currentMainBase.ResearchWait_ID)
            {
                loadType = currentMainBase.ResearchWait_ID;
                isSimilarCurUpgResType = false;
            }
        }

        refUpgType = SyncData.CurrentBaseUpgrade[loadType];
        if (!isSimilarCurUpgResType)
        {
            table    = dbReference[loadType];
            level    = refUpgType.Level;
            needInfo = table[level - 1];
        }


        string timeMin = GetPublicValue <string>(needInfo, "TimeMin"); // needInfo.TimeMin;
        int    timeInt = GetPublicValue <int>(needInfo, "TimeInt");    //needInfo.TimeInt;

        ActiveProgressBar(activeProgressBar && timeInt > 0);
        ProgressSlider.Slider.MaxValue = timeInt;


        bool isBuildingRequire = false;
        bool isResearchRequire = false;

        BuildingLevel.transform.parent.gameObject.SetActive(isBuildingRequire);
        ResearchLevel.transform.parent.gameObject.SetActive(isResearchRequire);

        #region display info
        Title.text = title;

        if (curMaterials != null && needMaterials != null)
        {
            for (int i = 0; i < 4; i++)
            {
                int captureInt = i;
                OrderMaterialElements[i].SelectableComp.OnClickEvents += delegate
                {
                    SetMaterialRequirement(captureInt, ++curMaterials[captureInt], needMaterials[captureInt]);
                    if (IsEnoughtMeterial(needMaterials))
                    {
                        ActiveBtnGroup(true);
                    }
                };
                SetMaterialRequirement(i, curMaterials[i], needMaterials[i]);
            }
        }

        // ============================ //
        NumberName.text = "Might Bonus";
        Amount.text     = string.Format("{0}", mightBonus);

        //DurationText.text = "Duration: " + timeMin;
        DurationText.text = timeMin;
        #endregion
    }
示例#24
0
 public ITable this[ListUpgrade type]
 {
     get { return(Singleton.Instance <DBReference>()[type]); }
 }
示例#25
0
 private void OnElementBtn(ListUpgrade type)
 {
     Group.Open(WindowType.UpgradeResearch);
     Group[WindowType.UpgradeResearch].Load(type);
 }
示例#26
0
 public static bool IsUpgrade(this ListUpgrade value)
 {
     return(HasAttribute <UpgradeAttribute>(value));
 }
示例#27
0
 public static bool IsDefined(this ListUpgrade e)
 {
     return(Enum.IsDefined(typeof(ListUpgrade), e));
 }