Example #1
0
        void Start()
        {
            //找到当前的国家对象组件
            countryObj = GetComponent <CountryObj>();
            //找到城市控制组件
            cityController = GetComponent <CityController>();
            //建造者列表
            builders = new List <TeamObj>();
            //被建造中的队伍模型(如Tank)列表
            newTeams = new List <GameObject>();
            //待激活的模型列表(根据国籍和兵种从newTeams中取得)
            models = new List <Transform>();

            if (!photonView.isMine)
            {
                return;
            }

            //UI控件定义
            WorldUI   = GameObject.Find("PlayerCamera").transform.Find("WorldUI(Clone)").transform;
            teamPanel = WorldUI.Find("TeamPanel");
            //heroInfoButton = teamPanel.Find("HeroInfoButton").GetComponent<Button>();
            heroSkillButton = teamPanel.Find("HeroSkillButton").GetComponent <Button>();
            teamInfoText    = teamPanel.Find("TeamInfoText").GetComponent <Text>();

            //点击事件添加
            //AddHeroInfoButtonListener();
            AddHeroSkillButtonListener();
        }
Example #2
0
        void Start()
        {
            WorldUI   = GameObject.Find("PlayerCamera").transform.Find("WorldUI(Clone)").transform;
            teamPanel = WorldUI.Find("TeamPanel");
            //确定所在国籍
            selfCountry = WorldObj.SelfCountry();

            cityController = selfCountry.GetComponent <CityController>();
            teamController = selfCountry.GetComponent <TeamController>();
            uiController   = selfCountry.GetComponent <UIController>();
        }
Example #3
0
        /// <summary>
        /// 同步更新战争状态
        /// </summary>
        /// <param name="_newDefence">新战争状态</param>
        public void UpdateFighting(bool _fighting)
        {
            CountryObj selfCountry = WorldObj.MatchCountry(nationality);

            if (selfCountry)
            {
                uiController = selfCountry.GetComponent <UIController>();
                uiController.ScoutInfoShow(nationality, WorldObj.AnimatorAction.Victory, WorldObj.ScoutInfoType.CityBeAttacked, this.gameObject);
            }

            photonView.RPC("UpdateFightingRPC", PhotonTargets.All, _fighting);
        }
Example #4
0
        /// <summary>
        /// 生成国家
        /// </summary>
        void SpawnCountry()
        {
            GameObject country;

            switch (PhotonNetwork.player.GetTeam())
            {
            case PunTeams.Team.red:
                country                = PhotonNetwork.Instantiate("Country", new Vector3(0f, 0f, -1f), Quaternion.identity, 0);
                countryobj             = country.GetComponent <CountryObj>();
                countryobj.nationality = Nationality.red;
                Debug.Log("该国国籍是:" + countryobj.nationality);
                break;

            case PunTeams.Team.blue:
                country                = PhotonNetwork.Instantiate("Country", new Vector3(0f, 0f, 1f), Quaternion.identity, 0);
                countryobj             = country.GetComponent <CountryObj>();
                countryobj.nationality = Nationality.blue;
                Debug.Log("该国国籍是:" + countryobj.nationality);
                break;

            default:
                break;
            }
        }
Example #5
0
 void Start()
 {
     //确定所在国籍
     selfCountry = WorldObj.SelfCountry();
 }
Example #6
0
        /// <summary>
        /// 设置应激活的模型和配件,并增加操作响应代码组件
        /// </summary>
        void ActivePartsAndAddComponent()
        {
            //确定所在国籍
            CountryObj selfCountry = null;

            foreach (var item in WorldObj.allCountries)
            {
                if (item.photonView.isMine)
                {
                    selfCountry = item;
                }
            }

            //为模型成品增加操作响应代码组件ModelController
            if (!modelRedRoot.GetComponent <ModelController>())
            {
                ModelController modelController = modelRedRoot.gameObject.AddComponent <ModelController>();
                modelController.modelChildren = modelRedChildren;
                modelController.model         = modelRedRoot;
            }
            if (!modelBlueRoot.GetComponent <ModelController>())
            {
                ModelController modelController = modelBlueRoot.gameObject.AddComponent <ModelController>();
                modelController.modelChildren = modelBlueChildren;
                modelController.model         = modelBlueRoot;
            }


            //为无色配件增加操作响应代码组件PartController
            for (int i = 0; i < partColorlessRoot.childCount; i++)
            {
                GameObject partColorless = partColorlessRoot.GetChild(i).gameObject;
                if (!partColorless.GetActive())
                {
                    partColorless.SetActive(true);
                }
                if (!partColorless.GetComponent <PartController>())
                {
                    PartController partController = partColorless.AddComponent <PartController>();
                    partController.modelRedRoot      = modelRedRoot;
                    partController.modelBlueRoot     = modelBlueRoot;
                    partController.modelRedChildren  = modelRedChildren;
                    partController.modelBlueChildren = modelBlueChildren;
                }
            }

            //根据国籍激活配件和模型的根节点,并增加操作响应代码组件
            switch (selfCountry.nationality)
            {
            case WorldObj.Nationality.red:
                modelRedRoot.gameObject.SetActive(true);
                partRedRoot.gameObject.SetActive(true);
                //为红方配件增加操作响应代码组件
                for (int i = 0; i < partRedRoot.childCount; i++)
                {
                    GameObject partRed = partRedRoot.GetChild(i).gameObject;
                    if (!partRed.GetActive())
                    {
                        partRed.SetActive(true);
                    }
                    if (!partRed.GetComponent <PartController>())
                    {
                        PartController partController = partRed.AddComponent <PartController>();
                        partController.modelRedRoot      = modelRedRoot;
                        partController.modelBlueRoot     = modelBlueRoot;
                        partController.modelRedChildren  = modelRedChildren;
                        partController.modelBlueChildren = modelBlueChildren;
                    }
                }
                break;

            case WorldObj.Nationality.blue:
                modelBlueRoot.gameObject.SetActive(true);
                partBlueRoot.gameObject.SetActive(true);
                //为蓝方配件增加操作响应代码组件
                for (int i = 0; i < partBlueRoot.childCount; i++)
                {
                    GameObject partBlue = partBlueRoot.GetChild(i).gameObject;
                    if (!partBlue.GetActive())
                    {
                        partBlue.SetActive(true);
                    }
                    if (!partBlue.GetComponent <PartController>())
                    {
                        PartController partController = partBlue.AddComponent <PartController>();
                        partController.modelRedRoot      = modelRedRoot;
                        partController.modelBlueRoot     = modelBlueRoot;
                        partController.modelRedChildren  = modelRedChildren;
                        partController.modelBlueChildren = modelBlueChildren;
                    }
                }
                break;

            case WorldObj.Nationality.monster:
                break;

            default:
                break;
            }
        }