Пример #1
0
        // ----------------------------------------------------------------------------------------------------
        #endregion

        #region Initialization
        // ----------------------------------------------------------------------------------------------------
        /// <summary>
        /// Called upon awaking this behavior.
        /// </summary>
        private void Awake()
        {
            this.spawnEffectPrefabID = spawnEffectPrefab.GetInstanceID();
            this.spawnEffectPool     = FeatherPoolManager.Instance.GetPool(this.spawnEffectPrefabID);

            this.teleportEffectPrefabID = teleportEffectPrefab.GetInstanceID();
            this.teleportEffectPool     = FeatherPoolManager.Instance.GetPool(this.teleportEffectPrefabID);

            this.playerStateController = this.GetComponent <PlayerStateController>();
            this.materialController    = this.GetComponent <ActorMaterialController>();

            this.playerStateController.OnDisable += (dataController) => {
                this.materialController.PrepareSpawn();
            };

            this.playerStateController.OnRespawn += (dataController, spawnData) => {
                this.materialController.PrepareSpawn();
            };

            this.playerStateController.OnSpawn += (dataController, spawnData) => {
                if (spawnData.IsSilentSpawn)
                {
                    this.spawnEffectPool.Spawn(transform.position);
                }
                this.materialController.DoSpawnEffect(spawnData.SpawnEffectMultiplier);
            };

            this.playerStateController.OnTeleport += (dataController, targetTransform) => {
                var effectObject = this.teleportEffectPool.Spawn(transform.position);
                effectObject.GetComponent <ParticleAttractor>().TargetTransform = targetTransform;
                this.materialController.DoDespawnEffect();
            };
        }
Пример #2
0
        // ----------------------------------------------------------------------------------------------------
        #endregion

        #region Exit Methods
        // ----------------------------------------------------------------------------------------------------
        /// <summary>
        /// Uses the exit.
        /// </summary>
        public void UseExit(PlayerStateController player)
        {
            if (this.isActive)
            {
                this.OnExitReached?.Invoke(this, player);
                this.isActive = false;
            }
        }
Пример #3
0
        // ----------------------------------------------------------------------------------------------------
        #endregion

        #region Initialization
        // ----------------------------------------------------------------------------------------------------
        private void Awake()
        {
            this.axisHorizontal = ReInput.mapping.GetActionId("Horizontal");
            this.axisVertical   = ReInput.mapping.GetActionId("Vertical");
            this.actionInteract = ReInput.mapping.GetActionId("Interact");

            this.playerController      = this.GetComponent <PlayerController>();
            this.playerStateController = this.GetComponent <PlayerStateController>();
            this.movementController    = this.GetComponent <MovementController>();
            this.player = ReInput.players.Players[0];
        }
Пример #4
0
        // ----------------------------------------------------------------------------------------------------
        #endregion

        #region Initialization
        // ----------------------------------------------------------------------------------------------------
        /// <summary>
        /// Called upon awaking this behavior.
        /// </summary>
        private void Awake()
        {
            this.effectPrefabID = effectPrefab.GetInstanceID();
            this.effectPool     = FeatherPoolManager.Instance.GetPool(this.effectPrefabID);

            this.playerStateController = this.GetComponent <PlayerStateController>();

            this.playerStateController.OnDeath += (dataController) => {
                this.effectPool.Spawn(transform.position);
            };
        }
Пример #5
0
 public void TeleportPlayer(PlayerStateController player, Transform targetTransform, bool isWithinSection = true)
 {
     if (isWithinSection)
     {
         StartCoroutine(player.TeleportTo(targetTransform));
     }
     else
     {
         this.playerOneState.TeleportAway(targetTransform);
     }
 }
Пример #6
0
        // ----------------------------------------------------------------------------------------------------
        #endregion

        #region Initialization
        // ----------------------------------------------------------------------------------------------------
        /// <summary>
        /// Called upon awaking this behavior.
        /// </summary>
        private void Awake()
        {
            var playerContainer = new GameObject("Players");

            playerContainer.transform.position   = this.transform.position;
            playerContainer.transform.rotation   = Quaternion.identity;
            playerContainer.transform.localScale = Vector3.one;
            //playerContainer.transform.SetParent(this.transform);

            this.playerOne      = GameObject.Instantiate(this.playerOnePrefab, playerContainer.transform, false).GetComponent <PlayerController>();
            this.playerOne.name = "Player One";
            this.playerOneState = this.playerOne.GetComponent <PlayerStateController>();
            this.playerOneState.Disable();

            this.playerTwo      = GameObject.Instantiate(this.playerTwoPrefab, playerContainer.transform, false).GetComponent <PlayerController>();
            this.playerTwo.name = "Player Two";
            this.playerTwoState = this.playerTwo.GetComponent <PlayerStateController>();
            this.playerTwoState.Disable();

            this.playerList.Add(this.playerOne);
            this.playerList.Add(this.playerTwo);


            this.OnPlayerRegistered   += (player) => { this.OnPlayerChanged?.Invoke(player); };
            this.OnPlayerUnregistered += (player) => { this.OnPlayerChanged?.Invoke(player); };

            this.playerOne.gameObject.SetActive(false);
            this.playerTwo.gameObject.SetActive(false);

            this.playerOne.GetComponent <InteractionController>().OnInteract += (pc, it) => {
                this.OnPlayerInteract?.Invoke(pc, it);
            };

            this.playerTwo.GetComponent <InteractionController>().OnInteract += (pc, it) => {
                this.OnPlayerInteract?.Invoke(pc, it);
            };
        }
Пример #7
0
        // ----------------------------------------------------------------------------------------------------
        #endregion

        #region Initialization
        // ----------------------------------------------------------------------------------------------------
        private void Awake()
        {
            this.stateController = this.GetComponent <PlayerStateController>();
        }
Пример #8
0
 private void SpawnPlayer(PlayerStateController player)
 {
     player.Respawn(0.5f);
 }