Exemple #1
0
    public void CalculateBuff()
    {
        mBuffInfoList.Clear();
        EventPackage eventPackage = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_Event) as EventPackage;
        UserPackage  userPackage  = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_User) as UserPackage;
        //cooperation
        int num = userPackage.GetManorPersonNumber();

        if (num >= 2)
        {
            NBuffInfo buff = new NBuffInfo();
            buff.type     = NBuffType.Cooperation;
            buff.configID = num;
            mBuffInfoList.Add(buff);
        }
        //world event
        var infoList = eventPackage.GetCurEventList();

        foreach (var info in infoList)
        {
            NBuffInfo buff = new NBuffInfo();
            buff.type     = NBuffType.WorldEvent;
            buff.configID = info.configID;
            mBuffInfoList.Add(buff);
        }
    }
Exemple #2
0
    void InitManor()
    {
        int number = userPackage.GetManorPersonNumber();

        for (int i = number; i < 4; i++)
        {
            manors[i].gameObject.SetActive(false);
        }
    }
Exemple #3
0
    public int GetTotalProEfficiency()
    {
        UserPackage userPackage = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_User) as UserPackage;
        double      sum         = 0;

        foreach (var pair in mBuildingInfoMap)
        {
            if (GetBuildingFuncByConfigID(pair.Value.configID) != BuildingFunc.Collect)
            {
                continue;
            }
            BUILDING buildingConfig = GetBuildingConfigDataByConfigID(pair.Value.configID);
            string   name           = buildingConfig.BldgFuncTableName;
            name = name.ToUpper();
            int level = GetBulidingLevelByConfigID(pair.Value.configID);

            var configMap  = ConfigDataStatic.GetConfigDataTable(name);
            var funcConfig = configMap[level];

            Type         type         = Type.GetType("com.nkm.framework.resource.data." + name);
            string       propertyName = name[0] + name.Substring(1).ToLower();
            PropertyInfo spdInfo      = type.GetProperty(propertyName + "Spd");
            int          spd          = (int)spdInfo.GetValue(funcConfig, null);
            sum += spd;
        }
        //add number buff
        int personNum = userPackage.GetManorPersonNumber();

        if (personNum == 2)
        {
            sum *= 1.6f;
        }
        if (personNum == 3)
        {
            sum *= 2.2f;
        }
        if (personNum == 4)
        {
            sum *= 2.8f;
        }
        return((int)((double)sum * userPackage.GetPlayerInterest()));
    }
Exemple #4
0
    public void RefreshState()
    {
        NBuildingInfo info       = sanctuaryPackage.GetBuildingInfo(buildingID);
        long          remainTime = 0;

        if (info == null)
        {
            mState = BuildingState.Locked;
            Building building = sanctuaryPackage.GetTypeBuilding(buildingType);
            if (building == null)
            {
                return;
            }
            //if under building's min visible level, hide the building
            if (!sanctuaryPackage.IsBuildingVisible(buildingType))
            {
                building.gameObject.SetActive(false);
            }
            else
            {
                building.gameObject.SetActive(true);
            }
        }
        else
        {
            BuildingFunc func = sanctuaryPackage.GetBuildingFuncByConfigID(info.configID);
            info.building.gameObject.SetActive(true);
            if (info.upgradeFinishTime > 0 && GlobalFunction.GetRemainTime(info.upgradeFinishTime, out remainTime))
            {
                mState = BuildingState.Upgrade;
            }
            else if (info.processUID != 0 && info.number > 0)
            {
                if (GlobalFunction.GetRemainTime(info.processFinishTime, out remainTime))
                {
                    mState = BuildingState.Craft;
                }
                else
                {
                    mState = BuildingState.Collect;
                }
            }
            else
            {
                mState = BuildingState.Idle;
            }
            //store number and update number
            if (func == BuildingFunc.Collect)
            {
                proNumber = info.number;
                BUILDING config = sanctuaryPackage.GetBuildingConfigDataByConfigID(info.configID);
                //print(string.Format("Buidlin={0}, number={1}", config.BldgName, info.number));
                sanctuaryPackage.GetProAttribute(info.configID, out proSpeed, out proCap);

                EventPackage eventPackage   = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_Event) as EventPackage;
                UserPackage  userPackage    = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_User) as UserPackage;
                BUILDING     buildingConfig = sanctuaryPackage.GetBuildingConfigDataByConfigID(info.configID);
                string       buildingName   = buildingConfig.BldgFuncTableName;
                buildingName = Char.ToUpper(buildingName[0]) + buildingName.Substring(1).ToLower();
                var eventList = eventPackage.GetCurEventList();
                foreach (var eventInfo in eventList)
                {
                    WORLD_EVENTS eventConfig = eventPackage.GetEventConfigDataByConfigID(eventInfo.configID);
                    if (eventConfig == null)
                    {
                        continue;
                    }
                    Type         type            = Type.GetType("com.nkm.framework.resource.data.WORLD_EVENTS");
                    PropertyInfo propertyInfo    = type.GetProperty(buildingName + "Bldgcap");
                    PropertyInfo hasPropertyInfo = type.GetProperty("Has" + buildingName + "Bldgcap");
                    bool         isHave          = (bool)hasPropertyInfo.GetValue(eventConfig, null);
                    if (isHave)
                    {
                        int effect = (int)propertyInfo.GetValue(eventConfig, null);
                        if (effect != 0)
                        {
                            proSpeed *= (float)effect / 100f;
                        }
                    }
                }
                //add person num
                int personNum = userPackage.GetManorPersonNumber();
                if (personNum == 2)
                {
                    proSpeed *= 1.6f;
                }
                else if (personNum == 3)
                {
                    proSpeed *= 2.2f;
                }
                else if (personNum == 4)
                {
                    proSpeed *= 2.8f;
                }
                if (proTimer != null)
                {
                    StopCoroutine(proTimer);
                }
                proTimer = StartCoroutine(ProduceTimer());
            }
        }
    }