Exemplo n.º 1
0
    private void Spawn()
    {
        if (player == null)
        {
            player     = GameManager.Instance.spawnedPlayer;
            spawnPoint = GameObject.Find("CreatureSpawn").transform;
        }

        // Spawns a creature if the user is not currently controlling a creature
        if (Input.GetButtonDown("Spawn") && (isPlayingCreature == false))
        {
            if (creature != null)
            {
                List <GameObject> tempList = new List <GameObject>();

                foreach (GameObject creature in spawnedCreatures)
                {
                    if (creature != null)
                    {
                        tempList.Add(creature);
                    }
                }

                foreach (GameObject creature in tempList)
                {
                    if (creature.tag == selectedCreature.tag)
                    {
                        spawnedCreatures.Remove(creature);
                        Destroy(creature.gameObject);
                    }
                }
            }
            creature = Instantiate(selectedCreature, spawnPoint) as GameObject;
            creature.transform.parent       = null;
            movement.moveableCharacter      = creature;
            cameraController.avatarToFollow = creature;
            isPlayingCreature = true;
            spawnedCreatures.Add(creature);

            if (AvatarChanged != null)
            {
                AvatarChanged.Invoke();
            }
        }
        // Destroys the currently controlled creature and swtiches back to main character
        else if (Input.GetButtonDown("Despawn") && (isPlayingCreature == true))
        {
            Despawn(creature);
        }
    }
Exemplo n.º 2
0
    public void Despawn(GameObject creatureToDespawn)
    {
        {
            movement.moveableCharacter      = player;
            cameraController.avatarToFollow = player;
            isPlayingCreature = false;

            if (AvatarChanged != null)
            {
                AvatarChanged.Invoke();
            }

            spawnedCreatures.Remove(creatureToDespawn);
            Destroy(creatureToDespawn);
        }
    }
Exemplo n.º 3
0
    private void ControlSelectedCreature()
    {
        foreach (GameObject creature in spawnedCreatures)
        {
            if (creature.tag == selectedCreature.tag)
            {
                movement.moveableCharacter      = creature;
                cameraController.avatarToFollow = creature;
                isPlayingCreature = true;

                if (AvatarChanged != null)
                {
                    AvatarChanged.Invoke();
                }
            }
        }
    }
Exemplo n.º 4
0
    private void Switch()
    {
        if (player == null)
        {
            player     = GameManager.Instance.spawnedPlayer;
            spawnPoint = GameObject.Find("CreatureSpawn").transform;
        }

        // Switches back to main character if the user is controlling a creature
        if (Input.GetButtonDown("Switch") && (isPlayingCreature == true))
        {
            movement.moveableCharacter      = player;
            cameraController.avatarToFollow = player;
            isPlayingCreature = false;

            if (AvatarChanged != null)
            {
                AvatarChanged.Invoke();
            }
        }
    }
        private void CustomAvatarLoaded(CustomAvatar loadedAvatar, AvatarLoadResult result)
        {
            if (result != AvatarLoadResult.Completed)
            {
                Logger.Log("Avatar " + loadedAvatar.FullPath + " failed to load");
                return;
            }

            Logger.Log("Loaded avatar " + loadedAvatar.Name + " by " + loadedAvatar.AuthorName);

            if (_currentSpawnedPlayerAvatar?.GameObject != null)
            {
                Object.Destroy(_currentSpawnedPlayerAvatar.GameObject);
            }

            _currentSpawnedPlayerAvatar = AvatarSpawner.SpawnAvatar(loadedAvatar, _playerAvatarInput);

            AvatarChanged?.Invoke(loadedAvatar);

            _avatarTailor.OnAvatarLoaded(_currentSpawnedPlayerAvatar);
            ResizePlayerAvatar();
            OnFirstPersonEnabledChanged(Plugin.Instance.FirstPersonEnabled);
        }
Exemplo n.º 6
0
 public static void OnAvatarChanged(object sender, UserPhotoChangedEventArgs e)
 {
     AvatarChanged?.Invoke(sender, e);
 }
Exemplo n.º 7
0
 protected virtual void OnAvatarChanged(object sender, string avatar)
 {
     AvatarChanged?.Invoke(this, avatar);
 }