Пример #1
0
        /// <summary>
        /// 设置玩家死亡
        /// </summary>
        public void SetPlayerDie()
        {
            playerCube.PlayerDie = true;

            //设置死亡面板显示
            playerDieUIComponent.DiePanel.SetActive(true);

            PlayerCubeControllerComponent playerCubeControllerComponent = playerCube.GetComponent <PlayerCubeControllerComponent>();

            //设置自己隐藏
            playerCubeControllerComponent.cubePlayerBody_Transform.gameObject.SetActive(false);

            //隐藏攻击箭头
            playerCubeControllerComponent.targetArrow.targetArrow_GameObject.SetActive(false);

            //隐藏控制UI
            VariableJoystickComponent variableJoystickController = playerCubeControllerComponent.cubePlayer_ControllerUI;

            variableJoystickController.OnPointerUp();
            variableJoystickController.GetParent <UI>().GameObject.SetActive(false);

            //隐藏攻击UI
            VariableJoystickComponent variableJoystickAttack = playerCubeControllerComponent.targetArrow.GetComponent <TargetArrowComponent>().AttackUI;

            variableJoystickAttack.OnPointerUp();
            variableJoystickAttack.GetParent <UI>().GameObject.SetActive(false);
        }
Пример #2
0
        /// <summary>
        /// 设置玩家复活
        /// </summary>
        public void SetPlayerResurrection(Vector3 ResurrectionPos)
        {
            playerCube.PlayerDie = false;

            //设置死亡面板显示
            playerDieUIComponent.DiePanel.SetActive(false);

            //设置血条
            SetPlayerCubeHealth(100);

            PlayerCubeControllerComponent playerCubeControllerComponent = playerCube.GetComponent <PlayerCubeControllerComponent>();

            //设置自己隐藏
            playerCube.cube_GameObject.transform.position = ResurrectionPos;
            playerCubeControllerComponent.cubePlayerBody_Transform.gameObject.SetActive(true);

            //隐藏攻击箭头
            playerCubeControllerComponent.targetArrow.targetArrow_GameObject.SetActive(true);

            //隐藏控制UI
            VariableJoystickComponent variableJoystickController = playerCubeControllerComponent.cubePlayer_ControllerUI;

            variableJoystickController.GetParent <UI>().GameObject.SetActive(true);

            //隐藏攻击UI
            VariableJoystickComponent variableJoystickAttack = playerCubeControllerComponent.targetArrow.GetComponent <TargetArrowComponent>().AttackUI;

            variableJoystickAttack.GetParent <UI>().GameObject.SetActive(true);
        }
        private static async ETVoid CreatePlayerCube(Vector3 InitPos, ETTaskCompletionSource <PlayerCube> tcs)
        {
            try
            {
                //创建一个cube角色的3D物体
                GameObject resObj = await ETModel.Game.Scene.GetComponent <ResourcesAsyncComponent>().LoadAssetAsync <GameObject>(Assets.LoadAssetAsync("Assets/Bundles/Prefab/PlayerCube.prefab", typeof(GameObject)));

                ReferenceCollector rc            = resObj.GetComponent <ReferenceCollector>();
                GameObject         playerCubeObj = GameObject.Instantiate <GameObject>(rc.Get <GameObject>("PlayerCube"));
                playerCubeObj.transform.position = InitPos;

                //创建cube角色实体脚本
                PlayerCube playerCube = ComponentFactory.Create <PlayerCube, GameObject>(playerCubeObj, false);

                //创建控制UI
                UI ui = await UIJoystickFactory.Create();

                Game.Scene.GetComponent <UIComponent>().Add(ui);

                //添加控制组件
                PlayerCubeControllerComponent playerCubeControllerComponent = playerCube.AddComponent <PlayerCubeControllerComponent, UI>(ui);

                //创建准星控制UI
                UI AttackUI = await UIAttackDirstickFactory.Create();

                Game.Scene.GetComponent <UIComponent>().Add(AttackUI);

                //创建准星3D物品
                TargetArrow targetArrow = await TargetArrowFactory.Create(Vector3.zero, playerCube, AttackUI);

                //管理准星与cube
                playerCubeControllerComponent.targetArrow = targetArrow;

                //添加攻击脚本
                playerCube.AddComponent <PlayerCubeAttackComponent>();

                //添加生命值信息UI
                playerCube.AddComponent <PlayerCubeHealthComponent>();

                //添加攻击伤害同步脚本
                playerCube.AddComponent <HurtSyncComponent>();

                tcs.SetResult(playerCube);
            }
            catch (Exception e)
            {
                Log.Error(e);
                tcs.SetResult(null);
            }
        }