Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
        public void Awake(PlayerCube playerCube, VariableJoystickComponent AttackUI)
        {
            this.cube_GameObject = playerCube.cube_GameObject;
            this.AttackUI        = AttackUI;

            //查找相关引用
            targetArrow_Transform = this.GetParent <TargetArrow>().targetArrow_GameObject.GetComponent <Transform>();
            SetTargetArrowPosition(cube_GameObject.transform.position);
            cubePlayer_CameraBaseTransform = cube_GameObject.transform.Find("PlayerCameraBase");
        }
        public void Awake(UI ui)
        {
            //查找相关引用
            playerCube                     = this.GetParent <PlayerCube>();
            cubePlayer_Transform           = playerCube.cube_GameObject.GetComponent <Transform>();
            cubePlayerBody_Transform       = cubePlayer_Transform.Find("CubeBody");
            cubePlayer_CameraBaseTransform = cubePlayer_Transform.Find("PlayerCameraBase");
            groundCheck                    = cubePlayerBody_Transform.Find("GroundCheck");
            cubePlayer_Controller          = cubePlayer_Transform.GetComponent <CharacterController>();


            cubePlayer_ControllerUI = ui.GetComponent <VariableJoystickComponent>();
        }
        public static async ETVoid CreateJoystickUI(ETTaskCompletionSource <UI> tcs)
        {
            try
            {
                AssetRequest assetRequest = Assets.LoadAssetAsync("Assets/Bundles/UI/" + UIType.UIJoystick + ".prefab", typeof(GameObject));

                //创建一个角色的3D物体
                GameObject bundleGameObject = await ETModel.Game.Scene.GetComponent <ResourcesAsyncComponent>().LoadAssetAsync <GameObject>(assetRequest);

                GameObject gameObject = UnityEngine.Object.Instantiate(bundleGameObject);

                UI ui = ComponentFactory.Create <UI, string, GameObject, AssetRequest>(UIType.UIJoystick, gameObject, assetRequest, false);

                VariableJoystickComponent variableJoystick = ui.AddComponent <VariableJoystickComponent>();
                variableJoystick.joystickType = JoystickType.Floating;
                tcs.SetResult(ui);
            }
            catch (Exception e)
            {
                Log.Error(e);
                tcs.SetResult(null);
            }
        }
        private static async ETVoid CreateTargetArrow(Vector3 InitPos, PlayerCube playerCube, VariableJoystickComponent AttackUI, ETTaskCompletionSource <TargetArrow> tcs)
        {
            try
            {
                //创建一个TargetArrow的3D物体
                GameObject resObj = await ETModel.Game.Scene.GetComponent <ResourcesAsyncComponent>().LoadAssetAsync <GameObject>(Assets.LoadAssetAsync("Assets/Bundles/Prefab/TargetArrow.prefab", typeof(GameObject)));

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

                //创建TargetArrow实体脚本
                TargetArrow targetArrow = ComponentFactory.Create <TargetArrow, GameObject>(targetArrowObj, false);

                //添加控制组件
                targetArrow.AddComponent <TargetArrowComponent, PlayerCube, VariableJoystickComponent>(playerCube, AttackUI);


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