public void RefreshCurrentMaterial()
    {
        OnCharacterChanged(currentCharacterType);

        //get the indexing right
        int index = CharacterTypes.IndexOf(GetComponent <PlayerController>().CharacterType);
        int indexRight, indexLeft;

        index      = (index + CharacterTypes.Count) % CharacterTypes.Count;
        indexRight = (index - 1 + CharacterTypes.Count) % CharacterTypes.Count;
        indexLeft  = (index + 1 + CharacterTypes.Count) % CharacterTypes.Count;

        nextCharacterType = CharacterTypes[indexRight];
        GameObject      nextGO = characterTypeAnimatorGOMappings[nextCharacterType];
        List <Material> nextMaterialOptions = CharacterTypeMaterialMappings[nextCharacterType];

        characterTypeAnimatorGOMappings[nextCharacterType].GetComponentInChildren <SkinnedMeshRenderer>().material = nextMaterialOptions[currentMaterialIndex];
        characterTypeAnimatorGOMappings[nextCharacterType].GetComponentInChildren <MeshRenderer>().material        = _gunMaterials[currentMaterialIndex];

        previousCharacterType = CharacterTypes[indexLeft];
        GameObject      previousGO = characterTypeAnimatorGOMappings[previousCharacterType];
        List <Material> prevMaterialOptions = CharacterTypeMaterialMappings[previousCharacterType];

        characterTypeAnimatorGOMappings[previousCharacterType].GetComponentInChildren <SkinnedMeshRenderer>().material = prevMaterialOptions[currentMaterialIndex];
        characterTypeAnimatorGOMappings[previousCharacterType].GetComponentInChildren <MeshRenderer>().material        = _gunMaterials[currentMaterialIndex];

        List <Material> currentMaterialOptions = CharacterTypeMaterialMappings[currentCharacterType];

        characterTypeAnimatorGOMappings[currentCharacterType].GetComponentInChildren <MeshRenderer>().material = _gunMaterials[currentMaterialIndex];
        SetCurrentMaterial(currentMaterialOptions[currentMaterialIndex]);
        OnPlayerColorChanged(CurrentPlayerColor);
    }
Exemple #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;
        }
    }
    public void OnCharacterTypeChange(PlayerCharacterType type)
    {
        DisplayedCharacterType = type;
        var pair = IconMappings.Find(x => x.Type == DisplayedCharacterType);

        CharacterIcon.sprite   = pair.Icon;
        CharacterTypeText.text = type.ToString();
    }
Exemple #4
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);
    }
Exemple #5
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;
     }
 }
        public ScriptableObjCharacter ReturnPlayerScriptableObj(PlayerCharacterType playerCharacterType)
        {
            for (int i = 0; i < playerList.playerObject.Count; i++)
            {
                if (playerCharacterType == playerList.playerObject[i].playerType)
                {
                    return(playerList.playerObject[i]);
                }
            }

            return(null);
        }
    public void ChangeToNextCharacterType(int dir)
    {
        //reset the player material incase its flashing
        SetCurrentMaterialLossy(CurrentPlayerMaterial);

        //get the indexing right
        int index = CharacterTypes.IndexOf(GetComponent <PlayerController>().CharacterType);
        int indexRight, indexLeft;

        index     += dir;
        index      = (index + CharacterTypes.Count) % CharacterTypes.Count;
        indexRight = (index - 1 + CharacterTypes.Count) % CharacterTypes.Count;
        indexLeft  = (index + 1 + CharacterTypes.Count) % CharacterTypes.Count;

        //set the current character
        currentCharacterType = CharacterTypes[index];

        GetComponent <PlayerController>().CharacterType = currentCharacterType;
        GameObject currentGO = characterTypeAnimatorGOMappings[currentCharacterType];

        CurrentPlayerMaterial = currentGO.GetComponentInChildren <SkinnedMeshRenderer>().material;
        GetComponent <CharacterAnimScript>().currentAnimator = currentGO.GetComponent <Animator>();
        currentGO.transform.localPosition = new Vector3(0, -1.33f, 0);
        currentGO.transform.localScale    = new Vector3(5, 5, 5);
        RefreshCurrentMaterial();
        OnCharacterChanged(currentCharacterType);

        //set the right character preview
        nextCharacterType = CharacterTypes[indexRight];
        GameObject nextGO = characterTypeAnimatorGOMappings[nextCharacterType];

        nextGO.transform.localPosition = new Vector3(1.5f, -1.33f, 0);
        nextGO.transform.localScale    = new Vector3(5f, 5f, 5f);

        //set the left character preview
        previousCharacterType = CharacterTypes[indexLeft];
        GameObject previousGO = characterTypeAnimatorGOMappings[previousCharacterType];

        previousGO.transform.localPosition = new Vector3(-1.5f, -1.33f, 0);
        previousGO.transform.localScale    = new Vector3(5f, 5f, 5f);

        if (LevelManager.Instance.ShowTutorialPrompt == true)
        {
            //reset selection time and update description
            descriptionCanvas.transform.GetChild(0).transform.GetChild(0).GetComponent <TextMeshProUGUI>().text     = GetComponent <PlayerController>().CharacterType.ToString();
            descriptionCanvas.transform.GetChild(0).transform.GetChild(1).GetComponent <UnityEngine.UI.Text>().text = CharacterTypeDescriptionMappings[GetComponent <PlayerController>().CharacterType];
            timeOnSelection = 0;
            descriptionCanvas.SetActive(false);
        }
    }
    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 void Init(GameObject playerPrefab)
    {
        Player     = Instantiate(playerPrefab);
        PlayerInfo = new PlayerInfo
        {
            mount = new MountInfo(150, 150, 100, 100)
        };
        characterType = PlayerSelector.Instance.characterType;
        CameraFollow camera = FindObjectOfType <CameraFollow>();

        camera.SetTarget(Player.transform);
        Player.GetComponentInChildren <MalbersAnimations.HAP.Rider3rdPerson>().AnimalStored = FindObjectOfType <MalbersAnimations.HAP.Mountable>();
        switch (characterType)
        {
        case PlayerCharacterType.Boy:
            PlayerInfo.SetCharacter(new CharacterInfo(100001, "李骁", "字天杰", "", 5, 4, 3, 2, 1, 10, 8, 4, 5));
            camera.headOffset         = new Vector3(0, 1.7f, 0);
            camera.transform.position = Player.transform.position + -Player.transform.forward * 2f + Player.transform.up * 1.7f;
            break;

        case PlayerCharacterType.Girl:
            PlayerInfo.SetCharacter(new CharacterInfo(100002, "李俏", "字婖洁", "", 4, 3, 3, 3, 2, 8, 6, 6, 5));
            camera.headOffset         = new Vector3(0, 1.6f, 0);
            camera.transform.position = Player.transform.position + -Player.transform.forward * 2f + Player.transform.up * 1.6f;
            break;

        case PlayerCharacterType.LittleGirl:
            PlayerInfo.SetCharacter(new CharacterInfo(100003, "李筱", "字恬婕", "", 3, 2, 1, 5, 4, 6, 6, 2, 5));
            camera.headOffset         = new Vector3(0, 1.2f, 0);
            camera.transform.position = Player.transform.position + -Player.transform.forward * 2f + Player.transform.up * 1.2f;
            break;
        }
        FindObjectOfType <bl_MiniMap>().SetTarget(Player);
        LevelUp(1);
        isInit = true;
        PlayerLocomotionManager.Instance.Init();
        PlayerWeaponManager.Instance.Init();
        BagManager.Instance.Init();
        WarehouseManager.Instance.Init();
        StartCoroutine(Auto_Recover());
    }
Exemple #11
0
 public static PlayerCharacter GetCharacterByType(PlayerCharacterType type)
 {
     return(Resources.Load <PlayerCharacter>(ScriptableObjectPaths.PlayerCharacterPath + type.ToString()));
 }
    public bool LoadPlayerInfo(string path, string key = "", bool dencrypt = false)
    {
        //try
        {
            if (File.Exists(path + "/PlayerInfoData.zetan"))
            {
                if (dencrypt && key.Length == 32)
                {
                    PlayerInfo.CopyInfo(JsonConvert.DeserializeObject <PlayerInfo>(Encryption.Dencrypt(File.ReadAllText(path + "/PlayerInfoData.zetan"), key)) ?? PlayerInfo);
                }
                else
                {
                    PlayerInfo.CopyInfo(JsonConvert.DeserializeObject <PlayerInfo>(File.ReadAllText(path + "/PlayerInfoData.zetan")) ?? PlayerInfo);
                }
                PlayerInfo.bag.Load(path, key, dencrypt);
                PlayerInfo.warehouseInfo.Load(path, key, dencrypt);
                #region 修复装备图标

                /*if (PlayerInfo.equipments.weapon != null)
                 * {
                 *  WeaponItem newWeapon = PlayerInfo.equipments.weapon.Clone() as WeaponItem;
                 *  PlayerInfo.bag.itemList.Add(new ItemInfo(newWeapon));
                 *  newWeapon.Equip(PlayerInfo);
                 * }
                 * if (PlayerInfo.equipments.shield != null)
                 * {
                 *  WeaponItem newShield = PlayerInfo.equipments.shield.Clone() as WeaponItem;
                 *  newShield.Equip(PlayerInfo);
                 * }
                 *
                 * if (PlayerInfo.equipments.clothes != null)
                 * {
                 *  ArmorItem newClothes = PlayerInfo.equipments.clothes.Clone() as ArmorItem;
                 *  newClothes.Equip(PlayerInfo);
                 * }
                 * if (PlayerInfo.equipments.helmet != null)
                 * {
                 *  ArmorItem newHelmet = PlayerInfo.equipments.helmet.Clone() as ArmorItem;
                 *  newHelmet.Equip(PlayerInfo);
                 * }
                 * if (PlayerInfo.equipments.wristband != null)
                 * {
                 *  ArmorItem newWristband = PlayerInfo.equipments.wristband.Clone() as ArmorItem;
                 *  newWristband.Equip(PlayerInfo);
                 * }
                 * if (PlayerInfo.equipments.shoes != null)
                 * {
                 *  ArmorItem newShoes = PlayerInfo.equipments.shoes.Clone() as ArmorItem;
                 *  newShoes.Equip(PlayerInfo);
                 * }
                 *
                 * if (PlayerInfo.equipments.necklace != null)
                 * {
                 *  JewelryItem newNecklace = PlayerInfo.equipments.necklace.Clone() as JewelryItem;
                 *  newNecklace.Equip(PlayerInfo);
                 * }
                 * if (PlayerInfo.equipments.belt != null)
                 * {
                 *  JewelryItem newBelt = PlayerInfo.equipments.belt.Clone() as JewelryItem;
                 *  newBelt.Equip(PlayerInfo);
                 * }
                 * if (PlayerInfo.equipments.ring_1 != null)
                 * {
                 *  JewelryItem newRing_1 = PlayerInfo.equipments.ring_1.Clone() as JewelryItem;
                 *  newRing_1.Equip(PlayerInfo);
                 * }
                 * if (PlayerInfo.equipments.ring_2 != null)
                 * {
                 *  JewelryItem newRing_2 = PlayerInfo.equipments.ring_2.Clone() as JewelryItem;
                 *  newRing_2.Equip(PlayerInfo);
                 * }*/
                #endregion
            }
            else
            {
                throw new System.Exception("存档不存在");
            }
            switch (PlayerInfo.ID)
            {
            case 100001: characterType = PlayerCharacterType.Boy; break;

            case 100002: characterType = PlayerCharacterType.Girl; break;

            case 100003: characterType = PlayerCharacterType.LittleGirl; break;
            }
            PlayerWeaponManager.Instance.CheckWeaponTypeForCharactor();
            PlayerWeaponManager.Instance.EquipWeapon();
            PlayerWeaponManager.Instance.NoWeapon();
            PlayerSkillManager.Instance.CheckSkillButtonEnable();
            BagManager.Instance.LoadFromBagInfo();
            WarehouseManager.Instance.LoadFromWarehouseInfo();
            return(true);
        }

        /*catch (System.Exception ex)
         * {
         *  Debug.Log(ex.Message);
         *  //if (NotificationManager.Self) NotificationManager.Self.NewNotification(ex.Message);
         *  return false;
         * }*/
    }