Ejemplo n.º 1
0
    private void Update()
    {
        PlayerControllerBase controller = PlayerControllerBase.GetActiveInstance();

        SpellBase[] spells = controller.Spells;

        for (int i = 0; i < spells.Length; i++)
        {
            cooldowns[i].text = controller.IsInCooldown(spells[i]) ? controller.GetCooldown(spells[i]).ToString("F1") : "";

            Color col = AVAILABLE;

            if (!spells[i].CompareLevelRequirement(controller))
            {
                col = UNAVAILABLE;
            }
            else if (!spells[i].VerifyCanCastSpell(controller, true))
            {
                col = UNUSABLE;
            }
            else
            {
                col = AVAILABLE;
            }

            renderers[i].color = Color.Lerp(renderers[i].color, col, Time.deltaTime * animationSpeed);

            if (controller.IsInCooldown(spells[i]))
            {
                cooldownOverlays[i].SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0F, BOX_SIZE.y * controller.GetCooldown(spells[i]) / spells[i].cooldown);
            }
        }
    }
Ejemplo n.º 2
0
    private void Start()
    {
        PlayerControllerBase controller = PlayerControllerBase.GetActiveInstance();

        hpValue = controller.life;
        xpValue = (float)PlayerData.Instance.Experience / PlayerData.Instance.ExperienceToNextLevel;
    }
Ejemplo n.º 3
0
    void Update()
    {
        PlayerControllerBase controller = PlayerControllerBase.GetActiveInstance();

        background.color = controller.Progress >= .0F ? baseColor : new Color(0F, 0F, 0F, 0F);

        if (controller.Progress >= .0F)
        {
            castText.text = Mathf.RoundToInt(controller.Progress * 100) + "%";
            castBar.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, castBarBg.rect.width * controller.Progress);
        }
    }
Ejemplo n.º 4
0
    public override void SetStack(ItemStack i, int slot)
    {
        PlayerControllerBase pc = PlayerControllerBase.GetActiveInstance();

        if (!pc)
        {
            return;
        }

        GameObject drop = new GameObject("drop");

        drop.AddComponent <EntityItem>().stack = i;
        drop.transform.position         = pc.transform.position + Vector3.up * .5F;
        drop.transform.localEulerAngles = new Vector3(0F, random.Next(-90, 90), 0);
    }
Ejemplo n.º 5
0
    private void OnMouseDown()
    {
        if (isZonerExit)
        {
            PlayerControllerBase.GetActiveInstance().OnKill();
            return;
        }

        GameObject player = GameObject.FindGameObjectWithTag("Player");

        if (Vector3.Distance(player.transform.position, transform.position) <= 5F)
        {
            player.transform.position = zonerLink;
        }
    }
Ejemplo n.º 6
0
    private void PickUp()
    {
        PlayerControllerBase inst = PlayerControllerBase.GetActiveInstance();

        if (!inst || Vector3.Distance(inst.transform.position, transform.position) > 5F)
        {
            return;
        }

        PlayerData data = PlayerData.Instance;

        if (data != null)
        {
            if (data.inventory.PlaceStack(stack))
            {
                Destroy(gameObject);
            }
        }
    }
Ejemplo n.º 7
0
    private void Update()
    {
        PlayerControllerBase controller = PlayerControllerBase.GetActiveInstance();
        PlayerData           data       = PlayerData.Instance;

        if (data == null)
        {
            return;
        }

        playerName.text = data.name;

        hpValue = Mathf.Lerp(hpValue, controller.life, Time.deltaTime * updateSpeed);
        xpValue = Mathf.Lerp(xpValue, (float)data.Experience / data.ExperienceToNextLevel, Time.deltaTime * updateSpeed);

        playerHP.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, playerHPBackground.rect.width * hpValue);
        playerHPVal.text = (int)(controller.life * controller.maxLife) + " / " + (int)controller.maxLife;

        playerXP.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, playerXPBackground.rect.width * xpValue);
        playerXPVal.text = data.Experience + " / " + data.ExperienceToNextLevel;

        playerLevel.text = "Level " + data.level;
        playerClass.text = i18n.Translate("player.class." + data.playerClass);
    }
Ejemplo n.º 8
0
    private void Start()
    {
        PlayerControllerBase controller = PlayerControllerBase.GetActiveInstance();

        SpellBase[] spells = controller.Spells;
        renderers        = new Image[spells.Length];
        cooldownOverlays = new RectTransform[spells.Length];
        cooldowns        = new Text[spells.Length];

        for (int i = 0; i < spells.Length; i++)
        {
            SpellBase spell = spells[i];

            GameObject go = new GameObject("spell");
            go.transform.SetParent(transform, false);

            renderers[i]        = go.AddComponent <Image>();
            renderers[i].sprite = Resources.Load <Sprite>("Icons/" + spell.icon);

            RectTransform rect = go.GetComponent <RectTransform>();

            rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, BOX_SIZE.x);
            rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, BOX_SIZE.y);

            GameObject spellOverlay = new GameObject("overlay");
            cooldownOverlays[i] = spellOverlay.AddComponent <RectTransform>();
            cooldownOverlays[i].SetParent(rect, false);

            cooldownOverlays[i].SetInsetAndSizeFromParentEdge(RectTransform.Edge.Bottom, 0F, 0F);

            spellOverlay.AddComponent <Image>().color = new Color(UNUSABLE.r, UNUSABLE.g, UNUSABLE.b, .5F);

            GameObject numberBackground = new GameObject("numberBackground");
            numberBackground.transform.SetParent(rect, false);

            Image numberBg = numberBackground.AddComponent <Image>();
            numberBg.color = new Color(0F, 0F, 0F, .75F);

            RectTransform bgRect = numberBackground.GetComponent <RectTransform>();

            bgRect.anchorMin = new Vector2(0F, 0F);
            bgRect.anchorMax = new Vector2(0F, 0F);
            bgRect.pivot     = new Vector2(0F, 0F);
            bgRect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 30F);
            bgRect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 30F);

            GameObject hotbarNumber = new GameObject("hotbarNumber");
            Text       numberText   = hotbarNumber.AddComponent <Text>();
            numberText.font      = Resources.GetBuiltinResource <Font>("Arial.ttf");
            numberText.fontSize  = 36;
            numberText.alignment = TextAnchor.MiddleCenter;
            numberText.transform.SetParent(numberBackground.transform, false);

            numberText.text = PlayerControllerBase.keyLabels[i];

            GameObject cooldownNumber = new GameObject("cooldownNumber");
            cooldowns[i]           = cooldownNumber.AddComponent <Text>();
            cooldowns[i].font      = Resources.GetBuiltinResource <Font>("Arial.ttf");
            cooldowns[i].fontSize  = 36;
            cooldowns[i].alignment = TextAnchor.MiddleCenter;
            cooldowns[i].transform.SetParent(rect, false);
            cooldowns[i].color = COOLDOWN_VALUE;
        }
    }