Example #1
0
        public async Task <RoleController> CreatePlayer2(PlayerData playerData = null)
        {
            playerPrefabName = playerPrefabName == null ? "Human" : playerPrefabName;
            playerPrefabName = playerPrefabName == "" ? "Human" : playerPrefabName;

            GameObject role = await AssetManager.InstantiateRole(playerPrefabName ?? "Human");

            role.name = "Player2";
            role.tag  = "Player2";

            role.AddComponentUnique <Player2InputController>();
            var roleController = role.GetComponent <RoleController>();

            var roleBehaviorTree = role.GetComponent <RoleBehaviorTree>();

            if (roleBehaviorTree != null)
            {
                Tools.Destroy(roleBehaviorTree);
            }

            roleController.RoleData.TeamId = "3";

            SceneManager.Instance.RoleEnterSceneWithLocalPosition(roleController, Player1.SceneId,
                                                                  new Vector3(Player1.transform.localPosition.x, Player1.transform.localPosition.y + 3,
                                                                              Player1.transform.localPosition.z));
            return(roleController);
        }
Example #2
0
        public async Task <RoleController> CreateXBoxplayer(string Id)
        {
            var        player = GameManager.Instance.Player1;
            GameObject role   = await AssetManager.InstantiateRole(Id);

            role.name = "Player2";
            role.tag  = "Player2";

            role.AddComponentUnique <Player2InputController>();
            var roleController = role.GetComponent <RoleController>();

            var roleBehaviorTree = role.GetComponent <RoleBehaviorTree>();

            if (roleBehaviorTree != null)
            {
                Tools.Destroy(roleBehaviorTree);
            }

            roleController.RoleData.TeamId = "3";

            SceneManager.Instance.RoleEnterSceneWithLocalPosition(roleController, player.SceneId,
                                                                  new Vector3(player.transform.localPosition.x, player.transform.localPosition.y + 3,
                                                                              player.transform.localPosition.z));
            return(roleController);
        }
Example #3
0
        public async void AddRole(string id, Vector3 pos)
        {
            var role = await AssetManager.InstantiateRole(id);

            Debug.Assert(role, "没有角色[" + id + "]");

            var roleController = role.GetComponent <RoleController>();

            roleController.RoleData.TeamId = "2";

            RoleEnterWithWorldPosition(roleController, GetRefreshPosition(pos));
        }
Example #4
0
        public async Task <RoleController> AddRole(string prefabId, string areaId)
        {
            var role = await AssetManager.InstantiateRole(prefabId);

            Debug.Assert(role, "没有角色[" + prefabId + "]");

            var roleController = role.GetComponent <RoleController>();

            roleController.RoleData.TeamId = "2";

            RoleEnterWithLocalPosition(roleController, GetAreaRandomPosition(areaId));
            return(roleController);
        }