示例#1
0
    private void Start()
    {
        healthBar.SetActive(true);

        //Initialize variables
        meshRender       = GetComponent <MeshRenderer>();
        combatStatistics = CombatStatistics.instance;
        equipmentHolder  = EquipmentHolder.instance;
        dataRetainer     = DataRetainer.instance;

        if (gameObject.tag == "Player")
        {
            playerLevel = dataRetainer.GetPlayerLevel(playerIndex);
        }

        maxHealth    = baseStatus.health + (int)(((playerLevel / 10.0) + baseStatus.health / 8.0) * playerLevel);
        health       = maxHealth;
        defense      = baseStatus.defense + (int)((baseStatus.defense / 4.0) * playerLevel);
        speed        = baseStatus.speed + (int)((baseStatus.speed / 4.0) * playerLevel);
        strength     = baseStatus.strength + (int)((baseStatus.strength / 4.0) * playerLevel);
        dexterity    = baseStatus.dexterity + (int)((baseStatus.dexterity / 4.0) * playerLevel);
        intelligence = baseStatus.intelligence + (int)((baseStatus.intelligence / 4.0) * playerLevel);
        maxMP        = 2 * intelligence;
        currentMp    = maxMP;

        //Calculate all status variables
        if (gameObject.tag == "Player")
        {
            //If it is a player we add the base status + the equipment status
            health    = dataRetainer.GetPlayerHealth(playerIndex);
            currentMp = dataRetainer.GetPlayerMP(playerIndex);

            maxHealth    += equipmentHolder.playersHealth[playerIndex];
            speed        += equipmentHolder.playersSpeed[playerIndex];
            defense      += equipmentHolder.playersDefense[playerIndex];
            strength     += equipmentHolder.playersStrength[playerIndex];
            dexterity    += equipmentHolder.playersDexterity[playerIndex];
            intelligence += equipmentHolder.playersIntelligence[playerIndex];

            xpNeeded  = baseStatus.xp + (4 * (playerLevel ^ 3)) / 7;
            currentXP = dataRetainer.GetPlayerXP(playerIndex);
        }

        //Set the UI
        damageText.text          = "";
        healthBarFill.fillAmount = (float)health / maxHealth;
        healthText.text          = "" + health + "/" + maxHealth;
        mpBar.fillAmount         = (float)currentMp / maxMP;
        mpText.text = "" + currentMp + "/" + maxMP;

        enemyCombatAI = EnemyCombatAI.instance;
    }
    private void Start()
    {
        dataRetainer    = DataRetainer.instance;
        equipmentHolder = EquipmentHolder.instance;

        //Set the UI
        currentHealth = dataRetainer.GetPlayerHealth(playerIndex);
        currentMP     = dataRetainer.GetPlayerMP(playerIndex);
        playerLevel   = dataRetainer.GetPlayerLevel(playerIndex);

        UpdatePlayerStatus();

        healthBar.fillAmount = (float)currentHealth / maxHealth;
        healthText.text      = "" + currentHealth + " / " + maxHealth;
        mpBar.fillAmount     = (float)currentMP / maxMP;
        mpText.text          = "" + currentMP + " / " + maxMP;

        xpNeeded  = baseStatus.xp + (4 * (playerLevel ^ 3)) / 7;
        currentXP = dataRetainer.GetPlayerXP(playerIndex);
    }