示例#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);
        }
    }
示例#2
0
    public void CalculateVisibleEvent()
    {
        EventPackage eventPackage = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_Event) as EventPackage;
        var          curEventList = eventPackage.GetCurEventList();

        foreach (NWorldEventInfo info in curEventList)
        {
            mVisibleEventList.Add(info);
        }

        var futureList = eventPackage.GetFutureEventList();

        foreach (NWorldEventInfo info in futureList)
        {
            if (eventPackage.IsVisible(info))
            {
                mVisibleEventList.Add(info);
            }
        }
    }
示例#3
0
    //Play BGM
    void RefreshBGM(NDictionary args = null)
    {
        bool isZombie  = false;
        var  eventList = eventPackage.GetCurEventList();

        foreach (NWorldEventInfo info in eventList)
        {
            if (eventPackage.GetEventType(info.configID) == WorldEventType.Zombie)
            {
                isZombie = true;
                break;
            }
        }
        SoundSingleton.Instance.StopAllBgm();
        if (isZombie)
        {
            SoundSingleton.Instance.PlayBGM("mainbgm1");
            if (soundCo != null)
            {
                StopCoroutine(soundCo);
            }
            soundCo = StartCoroutine(SoundTimer());
        }
        else
        {
            SoundSingleton.Instance.PlayBGM("mainbgm1");
            if (GlobalFunction.IsDayTime())
            {
                SoundSingleton.Instance.PlayBGM("bird");
            }
            else
            {
                SoundSingleton.Instance.PlayBGM("mainbgm1");
            }
        }
    }
示例#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());
            }
        }
    }