Exemple #1
0
    public IEnumerator Charge(float time)
    {
        chargeColors = new Pl_WeaponData.WeaponColors[0];
        while (time > 0.0f)
        {
            time   -= Time.deltaTime;
            charge += Time.deltaTime;

            if (charge > 1.0f)
            {
                Pl_WeaponData wpn = Pl_WeaponData.WeaponList[(int)curWeapon];
                if (wpn.chargeColors != null && wpn.chargeColors.Length > 0)
                {
                    int index = Mathf.Min(1, wpn.chargeColors.Length - 1);
                    chargeColors = new Pl_WeaponData.WeaponColors[wpn.chargeColors.Length / 2];
                    for (int i = 0; i < chargeColors.Length; i++)
                    {
                        chargeColors[i] = wpn.chargeColors[index, i];
                    }
                }
            }
            else if (charge > 0.3f)
            {
                Pl_WeaponData wpn = Pl_WeaponData.WeaponList[(int)curWeapon];
                if (wpn.chargeColors != null && wpn.chargeColors.Length > 0)
                {
                    int index = Mathf.Min(0, wpn.chargeColors.Length - 1);
                    chargeColors = new Pl_WeaponData.WeaponColors[wpn.chargeColors.Length / 2];
                    for (int i = 0; i < chargeColors.Length; i++)
                    {
                        chargeColors[i] = wpn.chargeColors[index, i];
                    }
                }
            }

            yield return(null);
        }
    }
    public override void DrawGUI()
    {
        // Draws everything.
        Vector2 cmrBase   = new Vector2(Camera.main.rect.x * Screen.width, Camera.main.rect.y * Screen.height);
        int     blockSize = (int)(Camera.main.pixelWidth / 16);

        GUI.contentColor = new Color32(56, 184, 248, 255);

        GUI.DrawTexture(new Rect(cmrBase.x, cmrBase.y, Camera.main.pixelWidth, Camera.main.pixelHeight), background);
        font.label.fontSize = (int)(blockSize * 0.5625f);

        // Draw the bolts
        Sprite bolt = (Sprite)Resources.LoadAll("Sprites/Stage/Items")[10];

        GUI.DrawTextureWithTexCoords(new Rect(cmrBase.x + 12.825f * blockSize,
                                              cmrBase.y + 1.45f * blockSize,
                                              1.0f * blockSize,
                                              1.0f * blockSize),
                                     bolt.texture, new Rect(bolt.textureRect.x / bolt.texture.width, bolt.textureRect.y / bolt.texture.height,
                                                            bolt.textureRect.width / bolt.texture.width, bolt.textureRect.height / bolt.texture.height));
        GUI.Label(new Rect(cmrBase.x + 14.3f * blockSize,
                           cmrBase.y + 1.7f * blockSize,
                           2.125f * blockSize,
                           1.0f * blockSize),
                  GameManager.bolts.ToString("0000"),
                  font.label);


        // Draw the player section
        for (int i = selectIndex_Player.z; i < Mathf.Min(playerData.Length, selectIndex_Player.z + 4); i++)
        {
            Sprite icon = playerData[i].sprite;
            if (!icon)
            {
                continue;
            }

            int j = i - selectIndex_Player.z;

            GUI.DrawTextureWithTexCoords(new Rect(cmrBase.x + 4.0f * blockSize + j * 2.25f * blockSize,
                                                  cmrBase.y + 0.875f * blockSize + (selectIndex_Player.x == i && mode == SelectModes.Players ? -blockSize * 0.25f : 0),
                                                  1.5f * blockSize,
                                                  1.5f * blockSize),
                                         icon.texture, new Rect(icon.textureRect.x / icon.texture.width, icon.textureRect.y / icon.texture.height,
                                                                icon.textureRect.width / icon.texture.width, icon.textureRect.height / icon.texture.height));
        }

        // Draw the weapon section
        for (int x = 0; x < Mathf.Min(owner.weaponList.Count, 2); x++)
        {
            for (int y = selectIndex_Weapon.z; y < Mathf.Min((owner.weaponList.Count + 2) / 2, selectIndex_Weapon.z + 6); y++)
            {
                if (y * 2 + x >= owner.weaponList.Count)
                {
                    break;
                }

                Pl_WeaponData weapon = Pl_WeaponData.WeaponList[(int)owner.weaponList[y * 2 + x]];

                if (weapon != null)
                {
                    Sprite icon = (selectIndex_Weapon.x == x && selectIndex_Weapon.y == y && mode == SelectModes.Weapons ? weapon.weaponIcon : weapon.weaponIconGray);
                    GUI.DrawTextureWithTexCoords(new Rect(cmrBase.x + 3.0f * blockSize + x * 5.0f * blockSize,
                                                          cmrBase.y + 3.5f * blockSize + (y - selectIndex_Weapon.z) * 1.0f * blockSize,
                                                          1.0f * blockSize,
                                                          1.0f * blockSize),
                                                 icon.texture, new Rect(icon.textureRect.x / icon.texture.width, icon.textureRect.y / icon.texture.height,
                                                                        icon.textureRect.width / icon.texture.width, icon.textureRect.height / icon.texture.height));
                    GUI.Label(new Rect(cmrBase.x + 4.25f * blockSize + x * 5.0f * blockSize,
                                       cmrBase.y + 3.5f * blockSize + (y - selectIndex_Weapon.z) * 1.0f * blockSize,
                                       6.0f * blockSize,
                                       1.0f * blockSize),
                              weapon.menuName,
                              font.label);

                    for (int i = 0; i < weapon.maxWeaponEnergy; i++)
                    {
                        icon = (weapon.weaponEnergy >= i ? weapon.menuBarFull : weapon.menuBarEmpty);
                        GUI.DrawTextureWithTexCoords(new Rect(cmrBase.x + 4.25f * blockSize + x * 5.0f * blockSize + i * 0.125f * blockSize,
                                                              cmrBase.y + 4.0f * blockSize + (y - selectIndex_Weapon.z) * 1.0f * blockSize,
                                                              0.125f * blockSize,
                                                              0.5f * blockSize),
                                                     icon.texture, new Rect(icon.textureRect.x / icon.texture.width, icon.textureRect.y / icon.texture.height,
                                                                            icon.textureRect.width / icon.texture.width, icon.textureRect.height / icon.texture.height));
                    }
                }
            }
        }


        int prevSize = font.label.fontSize;

        font.label.fontSize = (int)(blockSize * 0.6f);
        // Draw the recovery item section
        for (int i = selectIndex_RecItems.z; i < Mathf.Min((int)GameManager.RecoveryItems.Length, selectIndex_RecItems.z + 5); i++)
        {
            Sprite icon = recItemSprites[i];
            int    j    = i - selectIndex_RecItems.z;

            GUI.DrawTextureWithTexCoords(new Rect(cmrBase.x + 3.0f * blockSize + j * 1.0f * blockSize,
                                                  cmrBase.y + 10.375f * blockSize + (selectIndex_RecItems.x == i && mode == SelectModes.RecoveryItems ? -blockSize * 0.25f : 0),
                                                  1.0f * blockSize,
                                                  1.0f * blockSize),
                                         icon.texture, new Rect(icon.textureRect.x / icon.texture.width, icon.textureRect.y / icon.texture.height,
                                                                icon.textureRect.width / icon.texture.width, icon.textureRect.height / icon.texture.height));

            string num = GameManager.recItemsOwned[i].ToString("00");
            GUI.Label(new Rect(cmrBase.x + 3.125f * blockSize + j * 1.0f * blockSize,
                               cmrBase.y + 11.375f * blockSize,
                               2.0f * blockSize,
                               1.0f * blockSize),
                      num,
                      font.label);
        }

        // Draw the utility item section
        for (int i = 0; i < (int)GameManager.UtilityItems.Length; i++)
        {
            Sprite icon = utItemSprites[i];

            GUI.DrawTextureWithTexCoords(new Rect(cmrBase.x + 9.0f * blockSize + i * 1.0f * blockSize,
                                                  cmrBase.y + 10.375f * blockSize + (selectIndex_UtItems.x == i && mode == SelectModes.UtilityItems ? -blockSize * 0.25f : 0),
                                                  1.0f * blockSize,
                                                  1.0f * blockSize),
                                         icon.texture, new Rect(icon.textureRect.x / icon.texture.width, icon.textureRect.y / icon.texture.height,
                                                                icon.textureRect.width / icon.texture.width, icon.textureRect.height / icon.texture.height));

            string num = GameManager.utItemsOwned[i].ToString("00");
            GUI.Label(new Rect(cmrBase.x + 9.125f * blockSize + i * 1.0f * blockSize,
                               cmrBase.y + 11.375f * blockSize,
                               2.0f * blockSize,
                               1.0f * blockSize),
                      num,
                      font.label);
        }

        // Draw the lower text section
        font.label.fontSize = (int)(blockSize * 0.7f);

        float prevLength = 0.0f;

        for (int i = 0; i < lowerTexts.Length; i++)
        {
            GUI.Label(new Rect(cmrBase.x + (3.0f + prevLength * 0.5f + 0.5f) * blockSize,
                               cmrBase.y + 12.25f * blockSize,
                               3.0f * blockSize,
                               1.0f * blockSize),
                      lowerTexts[i],
                      font.label);

            if (mode == SelectModes.LowerText && selectIndex_LowerText.x == i)
            {
                GUI.Label(new Rect(cmrBase.x + (3.0f + prevLength * 0.5f + 0.125f) * blockSize,
                                   cmrBase.y + 12.25f * blockSize,
                                   3.0f * blockSize,
                                   1.0f * blockSize),
                          ">",
                          font.label);
            }

            prevLength += lowerTexts[i].Length + 1.0f;
        }



        font.label.fontSize = prevSize;
    }
Exemple #3
0
    public IEnumerator SetWeapon(Pl_WeaponData.Weapons weapon)
    {
        Pl_WeaponData.Weapons oldWeapon = curWeapon;
        Pl_WeaponData         wpn       = Pl_WeaponData.WeaponList[(int)weapon];

        if (Player.instance != null)
        {
            if (Player.instance.bodyColorDark && Player.instance.bodyColorDark.GetComponent <Misc_CopySprite>() != null)
            {
                cοpy_dark.spritePath = Player.instance.bodyColorDark.GetComponent <Misc_CopySprite>().spritePath;
            }
            if (Player.instance.bodyColorLight && Player.instance.bodyColorLight.GetComponent <Misc_CopySprite>() != null)
            {
                cοpy_light.spritePath = Player.instance.bodyColorLight.GetComponent <Misc_CopySprite>().spritePath;
            }
            if (Player.instance.bodyColorOutline && Player.instance.bodyColorOutline.GetComponent <Misc_CopySprite>() != null)
            {
                cοpy_outline.spritePath = Player.instance.bodyColorOutline.GetComponent <Misc_CopySprite>().spritePath;
            }
            cοpy_solids.spritePath = GameManager.GetPlayerSpritePath(Player.instance.curPlayer);
            cοpy_solids.spritePath = cοpy_solids.spritePath.Substring(0, cοpy_solids.spritePath.Length - 4) + "Blank";

            if (wpn != null)
            {
                defaultColors = wpn.baseColors;

                if (defaultColors.colorDark.a == 0)
                {
                    spr_dark.color = Player.instance.defaultColors.colorDark;
                }
                else
                {
                    spr_dark.color = defaultColors.colorDark;
                }
                if (defaultColors.colorLight.a == 0)
                {
                    spr_light.color = Player.instance.defaultColors.colorLight;
                }
                else
                {
                    spr_light.color = defaultColors.colorLight;
                }
                if (defaultColors.colorOutline.a == 0)
                {
                    spr_outline.color = Player.instance.defaultColors.colorOutline;
                    spr_solids.color  = Player.instance.defaultColors.colorOutline;
                }
                else
                {
                    spr_outline.color = defaultColors.colorOutline;
                    spr_solids.color  = defaultColors.colorOutline;
                }

                ChangeColors(new Pl_WeaponData.WeaponColors(spr_light.color, spr_dark.color, spr_outline.color));
                defaultColors = new Pl_WeaponData.WeaponColors(spr_light.color, spr_dark.color, spr_outline.color);
            }
            else
            {
                spr_dark.color    = Player.instance.defaultColors.colorDark;
                spr_light.color   = Player.instance.defaultColors.colorLight;
                spr_outline.color = Player.instance.defaultColors.colorOutline;
                spr_solids.color  = Player.instance.defaultColors.colorOutline;

                defaultColors = new Pl_WeaponData.WeaponColors(spr_light.color, spr_dark.color, spr_outline.color);
            }

            cοpy_dark.Reload();
            cοpy_light.Reload();
            cοpy_outline.Reload();
            cοpy_solids.Reload();

            curPlayer = Player.instance.curPlayer;
            curWeapon = weapon;
        }
        else
        {
            cοpy_solids.spritePath = GameManager.GetPlayerSpritePath(GameManager.Players.MegaMan);
            cοpy_solids.spritePath = cοpy_solids.spritePath.Substring(0, cοpy_solids.spritePath.Length - 4) + "Blank";
            cοpy_solids.Reload();

            curWeapon = weapon;
        }

        if (curWeapon != oldWeapon)
        {
            charge = 0.0f;
        }

        yield return(new WaitForSeconds(0.125f));
    }
    public IEnumerator Heal(float units, bool recoverHealth, bool recoverWeapons, GameManager.RecoveryItems recItem)
    {
        if (!recoverHealth && !recoverWeapons)
        {
            Debug.LogWarning("You aren't healing or recovering weapon energy. Possible oversight.");
            yield break;
        }

        // If there is no item, cancel.
        if (GameManager.recItemsOwned[(int)recItem] <= 0)
        {
            yield break;
        }

        // Recovers health and energy slowly.
        // Counts how many loops have happened.
        int loops = 0;

        while (units > 0)
        {
            // Checks if nothing was recovered the last frame to stop the loop.
            bool recoveredAnything = false;
            if (recoverHealth)
            {
                if (owner.health < owner.maxHealth)
                {
                    owner.health     += Mathf.Min(units, 1);
                    owner.health      = Mathf.Clamp(owner.health, 0, owner.maxHealth);
                    recoveredAnything = true;
                }
            }

            if (recoverWeapons)
            {
                foreach (Pl_WeaponData.Weapons wpnIndex in owner.weaponList)
                {
                    Pl_WeaponData wpn = Pl_WeaponData.WeaponList[(int)wpnIndex];

                    if (wpn.weaponEnergy < wpn.maxWeaponEnergy)
                    {
                        wpn.weaponEnergy += Mathf.Min(units, 1);
                        wpn.weaponEnergy  = Mathf.Clamp(wpn.weaponEnergy, 0, wpn.maxWeaponEnergy);
                        recoveredAnything = true;
                    }
                }
            }

            // If there is no health or weapon energy recovered, there is no reason to use the item.
            // As it can't be known if everything is full beforehand without looping through everything,
            // and as it is done here anyway, we check within the final loop if anything has recovered.
            if (!recoveredAnything)
            {
                if (loops == 0)
                {
                    yield break;
                }
                break;
            }

            // Plays recovery sound and adds to variables.
            owner.audioStage.PlaySound(owner.SFXLibrary.healthRecover, true);

            units--;
            loops++;

            yield return(new WaitForSecondsRealtime(0.05f));
        }

        // Consumes item.
        GameManager.recItemsOwned[(int)recItem] -= 1;
    }