Exemplo n.º 1
0
 /// <summary>
 /// 打开选项菜单面板
 /// </summary>
 void OpenOptionsMenuPanel()
 {
     //关闭所有面板
     uiController.CloseAllPanels();
     //设置UI运行为真
     WorldObj.UIRun = true;
     //激活选项菜单面板
     OptionsMenuPanel.gameObject.SetActive(true);
 }
Exemplo n.º 2
0
        //关闭建造窗口并提示建造
        void CloseSelectAndHintBuild()
        {
            //关闭建造窗口
            uiController.CloseAllPanels();
            //打开世界UI
            WorldUI.gameObject.SetActive(!cityController.BuildWeaponPanel.gameObject.GetActive());
            //队伍提示面板关闭
            teamPanel.gameObject.SetActive(false);
            //提示选择位置建造信息
            uiController.ScoutInfoShow(selfCountry.nationality, WorldObj.AnimatorAction.Victory, WorldObj.ScoutInfoType.WhereBuild, teamController.teamObj.gameObject);

            //生成提示建造模型
            if (model)
            {
                Transform aHintModel = teamController.teamObj.hintModel;
                if (aHintModel)
                {
                    Destroy(teamController.teamObj.hintModel.gameObject);
                }
                //生成提示模型
                aHintModel = Instantiate(model, teamController.teamObj.transform.position + new Vector3(0f, 1.5f, 2f), Quaternion.Euler(20f, 0f, 0f));
                //按配件信息字符串数组激活模型的部分配件
                cityController.SetActiveParts(aHintModel, teamController.teamObj.partsnames);
                //删除提示模型上的组件
                Destroy(aHintModel.GetComponent <Animator>());
                Destroy(aHintModel.GetComponent <Collider>());
                Destroy(aHintModel.GetComponent <ModelController>());
                Destroy(aHintModel.GetComponentInChildren <Animator>());
                Destroy(aHintModel.GetComponentInChildren <Animation>());
                //使提示模型半透明

                /*
                 * MeshRenderer[] meshRenderers = teamController.hintModel.GetComponentsInChildren<MeshRenderer>();
                 * foreach (var item in meshRenderers)
                 * {
                 *  foreach (var child in item.materials)
                 *  {
                 *     child.shader = Shader.Find("Transparent/Diffuse");
                 *      Color c = child.color;
                 *      c = new Color(c.r, c.g, c.b, c.a*2/ 5);
                 *      child.color = c;
                 *  }
                 * }
                 */
                //一定时间后删除
                //Destroy(teamController.hintModel.gameObject,10f);
                //模型跟随闪烁提示建造
                teamController.ModelFlashHint(aHintModel, teamController.teamObj.transform);

                teamController.teamObj.hintModel = aHintModel;
            }
        }
Exemplo n.º 3
0
        private void FixedUpdate()
        {
            if (!photonView.isMine)
            {
                return;
            }

            //如果更换场景摄像头被Destroy了则playercamera指向新场景的摄像头
            if (!playercamera)
            {
                playercamera = FindObjectOfType <Camera>().transform;
            }

            if (!Ground)
            {
                Ground = GameObject.Find("Ground(Clone)").transform;
            }

            cooltime += Time.deltaTime;
            if (cooltime >= 0.2f)
            {
                cooltime = 0f;
                //每10帧判断敌人队伍是否应该被看见
                foreach (var item in WorldObj.allTeams)
                {
                    //判断每一支非己方的TeamObj是否该被看见
                    if (item.nationality != nationality)
                    {
                        bool       seen       = false; //是否该被看见变量
                        GameObject infoSource = null;
                        foreach (var team in WorldObj.allTeams)
                        {
                            if (team.nationality == nationality)
                            {
                                if (Vector3.Distance(item.transform.position, team.transform.position) < WorldObj.SkillDistance)
                                {
                                    seen       = true;
                                    infoSource = team.gameObject;
                                    break;
                                }
                            }
                        }
                        foreach (var eachcity in WorldObj.allCities)
                        {
                            if (eachcity && eachcity.nationality == nationality)
                            {
                                if (Vector3.Distance(item.transform.position, eachcity.transform.position) < WorldObj.SkillDistance)
                                {
                                    seen       = true;
                                    infoSource = eachcity.gameObject;
                                    break;
                                }
                            }
                        }


                        //根据判断结果使敌人消失或者显形(包括敌人血条teamHealthCanvas)
                        if (seen && !item.visible) //使显形
                        {
                            item.visible = true;
                            StartCoroutine(Funcs.SlowDisappearIE(item.teamHealthCanvas, 2f, 100f, true));
                            StartCoroutine(Funcs.SlowDisappearIE(item.transform, 2f, 100f, true));
                            try
                            {
                                //侦查信息显示
                                uiController.ScoutInfoShow(nationality, WorldObj.AnimatorAction.Victory, WorldObj.ScoutInfoType.EnemyBeFound, infoSource);
                            }
                            catch (Exception)
                            {
                            }
                        }
                        else if (!seen && item.visible)//使消失
                        {
                            item.visible = false;
                            StartCoroutine(Funcs.SlowDisappearIE(item.teamHealthCanvas, 2f, 100f, false));
                            StartCoroutine(Funcs.SlowDisappearIE(item.transform, 2f, 100f, false));
                        }
                    }
                }
            }


            //如果正在操作界面的城市受到攻击,则关闭UI
            if (cityController.cityObj && cityController.cityObj.fighting && WorldObj.UIRun)
            {
                uiController.CloseAllPanels();
            }

            //如果城市的敌人列表中的队伍不再攻城或者已经不存在,则从列表中清除该队伍
            foreach (var item in WorldObj.allCities)
            {
                if (item && item.fighting)
                {
                    for (int i = 0; i < item.enemies.Count; i++)
                    {
                        TeamObj fightTeam = null;
                        foreach (var eachTeam in WorldObj.allTeams)
                        {
                            if (eachTeam.hero == item.enemies[i])
                            {
                                fightTeam = eachTeam;
                            }
                        }

                        if ((fightTeam && !fightTeam.enemies.Contains(item.word)) || !fightTeam)
                        {
                            item.UpdateEnemies(item.enemies[i], false);
                        }
                        if (item.enemies.Count == 0)
                        {
                            item.UpdateFighting(false);
                        }
                    }
                }
            }
        }