Beispiel #1
0
    public static PlayerCharacter GetCharacterLeft()
    {
        if (CharacterSelector.AreAllPlayersDead() == true)
        {
            Debug.LogError("GAME OVER!");
            return(null);
        }

        PlayerCharacter nextPlayer = null;

        if (CharacterSelector.currentCharacterIndex == 0)
        {
            CharacterSelector.currentCharacterIndex = CharacterSelector.characterNameList.Count - 1;
            nextPlayer = CharacterSelector.GetCharacterByType(CharacterSelector.characterNameList[CharacterSelector.characterNameList.Count - 1]);

            if (nextPlayer.isDead == true)
            {
                return(CharacterSelector.GetCharacterLeft());
            }

            return(nextPlayer);
        }

        nextPlayer = CharacterSelector.GetCharacterByType(CharacterSelector.characterNameList[--CharacterSelector.currentCharacterIndex]);

        if (nextPlayer.isDead == true)
        {
            return(CharacterSelector.GetCharacterLeft());
        }

        return(nextPlayer);
    }
Beispiel #2
0
    public override void DropEquipment(Equipment equipmentToDrop)
    {
        if (equipmentToDrop.equippableCreatureType == CreatureType.None)
        {
            return;
        }

        PlayerCharacterType playerCharacterType     = this.GetPlayerCharacterFromEquipmentClass(equipmentToDrop.equippableCreatureType);
        PlayerCharacter     selectedPlayerCharacter = CharacterSelector.GetCharacterByType(playerCharacterType);

        switch (equipmentToDrop.equipmentType)
        {
        case EquipmentType.Weapon:
            GameManager.GenerateGrabbableWeapon(this.transform.position, selectedPlayerCharacter.weapon);
            selectedPlayerCharacter.weapon = Resources.Load <Weapon>(ScriptableObjectPaths.WeaponsPath + "Unarmed");
            this.SetActiveWeaponIfCurrentCharacter(selectedPlayerCharacter, selectedPlayerCharacter.weapon);
            break;

        case EquipmentType.Armor:
            GameManager.GenerateGrabbableArmor(this.transform.position, selectedPlayerCharacter.armor);
            selectedPlayerCharacter.armor = Resources.Load <Armor>(ScriptableObjectPaths.ArmorPath + "Naked");
            this.SetActiveArmorIfCurrentCharacter(selectedPlayerCharacter, selectedPlayerCharacter.armor);
            break;

        default:
            Debug.Log("Player.DropEquipment: Unknown EquipmentType: " + equipmentToDrop.equipmentType + ". Unable to drop equipment");
            break;
        }
    }
Beispiel #3
0
    public override void EquipArmor(Armor armorToEquip)
    {
        PlayerCharacterType playerCharacterType     = this.GetPlayerCharacterFromEquipmentClass(armorToEquip.equippableCreatureType);
        PlayerCharacter     selectedPlayerCharacter = CharacterSelector.GetCharacterByType(playerCharacterType);

        this.DropEquipment(selectedPlayerCharacter.armor);
        selectedPlayerCharacter.armor = armorToEquip;
        this.SetActiveArmorIfCurrentCharacter(selectedPlayerCharacter, selectedPlayerCharacter.armor);
    }
Beispiel #4
0
    public override void EquipWeapon(Weapon weaponToEquip)
    {
        PlayerCharacterType playerCharacterType     = this.GetPlayerCharacterFromEquipmentClass(weaponToEquip.equippableCreatureType);
        PlayerCharacter     selectedPlayerCharacter = CharacterSelector.GetCharacterByType(playerCharacterType);

        this.DropEquipment(selectedPlayerCharacter.weapon);
        selectedPlayerCharacter.weapon = weaponToEquip;
        this.SetActiveWeaponIfCurrentCharacter(selectedPlayerCharacter, selectedPlayerCharacter.weapon);
    }
 private static void AttemptReviveCharacter()
 {
     //Revive player character
     while (PlayerHealthBarManager.currentTotalHitPoints > PlayerHealthBarManager.totalAliveCharacterHitPoints && PlayerHealthBarManager.deadCharacters.Count > 0)
     {
         PlayerCharacterType revivingPlayerCharacterType = PlayerHealthBarManager.deadCharacters.Pop();
         PlayerHealthBarManager.aliveCharacters.Push(revivingPlayerCharacterType);
         PlayerCharacter revivingCharacter = CharacterSelector.GetCharacterByType(revivingPlayerCharacterType);
         revivingCharacter.isDead = false;
         PlayerHealthBarManager.totalAliveCharacterHitPoints += revivingCharacter.hitPoints;
     }
 }
    private static void AttemptKillCharacter()
    {
        PlayerCharacter topAliveCharacter = CharacterSelector.GetCharacterByType(PlayerHealthBarManager.aliveCharacters.Peek());

        //Kill player characters
        while (PlayerHealthBarManager.currentTotalHitPoints <= (PlayerHealthBarManager.totalAliveCharacterHitPoints - topAliveCharacter.hitPoints))
        {
            PlayerCharacterType dyingPlayerCharacterType = PlayerHealthBarManager.aliveCharacters.Pop();
            PlayerHealthBarManager.deadCharacters.Push(dyingPlayerCharacterType);
            topAliveCharacter.isDead = true;
            topAliveCharacter.weapon.currentlyAttacking          = false;
            PlayerHealthBarManager.totalAliveCharacterHitPoints -= topAliveCharacter.hitPoints;

            topAliveCharacter = CharacterSelector.GetCharacterByType(PlayerHealthBarManager.aliveCharacters.Peek());
        }
    }
    public static void SetupPlayerHealthBarManager(List <PlayerCharacterType> orderedPlayerCharacterList)
    {
        PlayerHealthBarManager.aliveCharacters = new Stack <PlayerCharacterType>();
        PlayerHealthBarManager.deadCharacters  = new Stack <PlayerCharacterType>();

        foreach (PlayerCharacterType character in orderedPlayerCharacterList)
        {
            PlayerHealthBarManager.aliveCharacters.Push(character);
            PlayerHealthBarManager.totalAliveCharacterHitPoints += CharacterSelector.GetCharacterByType(character).hitPoints;
        }

        PlayerHealthBarManager.currentTotalHitPoints = PlayerHealthBarManager.totalAliveCharacterHitPoints;
        PlayerHealthBarManager.totalMaxHitPoints     = PlayerHealthBarManager.totalAliveCharacterHitPoints;

        Debug.LogError("Total HP: " + PlayerHealthBarManager.currentTotalHitPoints);
    }
Beispiel #8
0
 public void Start()
 {
     this.currentCharacter = CharacterSelector.GetCharacterByType(PlayerCharacterType.Warrior);
     this.SwapCharacter(this.currentCharacter);
 }