Ejemplo n.º 1
0
    void Start()
    {
        trail      = transform.Find("Trail");
        controller = GetComponent <Controller2D>();
        creature   = GetComponent <PlayerCreature>();
        stats      = creature.stats;
        anim       = GetComponent <Animator>();

        gravity         = -(2 * maxJumpHeight) / Mathf.Pow(timeToJumpApex, 2);
        maxJumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
        minJumpVelocity = Mathf.Sqrt(2 * Mathf.Abs(gravity) * minJumpHeight);
    }
Ejemplo n.º 2
0
    void Update()
    {
        if (player == null)
        {
            player = GameObject.FindGameObjectWithTag("Player");
            return;
        }
        LivingCreature.Statistics stats = player.GetComponent <PlayerCreature>().stats;
        PlayerCreature            pc    = player.GetComponent <PlayerCreature>();

        switch (chooseStat)
        {
        case Stat.HP:
        {
            RectTransform rt   = GetComponent <RectTransform>();
            float         stat = stats.maxHealth;
            rt.sizeDelta = new Vector2(stat, rt.sizeDelta.y);
            bg.sizeDelta = new Vector2(stat, rt.sizeDelta.y);

            GetComponent <Image>().fillAmount = Mathf.Lerp(GetComponent <Image>().fillAmount, (float)stats.curHealth / stats.maxHealth, 0.15f);
            break;
        }

        case Stat.Stamina:
        {
            RectTransform rt   = GetComponent <RectTransform>();
            float         stat = stats.maxStamina;
            rt.sizeDelta = new Vector2(stat, rt.sizeDelta.y);
            bg.sizeDelta = new Vector2(stat, rt.sizeDelta.y);

            GetComponent <Image>().fillAmount = Mathf.Lerp(GetComponent <Image>().fillAmount, stats.curStamina / stats.maxStamina, 0.15f);
            break;
        }

        case Stat.RH:
        {
            RectTransform rt   = GetComponent <RectTransform>();
            float         stat = stats.maxHealth;
            rt.sizeDelta = new Vector2(stat, rt.sizeDelta.y);

            GetComponent <Image>().fillAmount = Mathf.Lerp(GetComponent <Image>().fillAmount, (float)(stats.curHealth + pc.healthToRestore) / stats.maxHealth, 0.15f);
            break;
        }
        }
    }
Ejemplo n.º 3
0
    void AnimationSummon()
    {
        GameObject clone = Instantiate(summon, spawnPoint.position, Quaternion.identity);

        LivingCreature.Statistics      stats = clone.GetComponent <SummonCreature>().stats;
        WeaponController.Weapon.Attack atk   = WeaponController.wc.eqWeaponCurAttack;
        stats.damage         = atk.baseDamage;
        stats.knockbackPower = atk.knockbackPower;

        if (atk.crit)
        {
            Color swingColor = clone.GetComponent <SpriteRenderer>().color;
            swingColor = new Color(1f, 0.5f, 0.5f);
            clone.GetComponent <SpriteRenderer>().color = swingColor;

            stats.maxHealth = (int)(atk.criticalMultiplier * stats.maxHealth);
            stats.Initialize();
            stats.damage = atk.criticalDamage;
        }

        clone.transform.parent = GameObject.Find("PlayerSummons").transform;
        summons.Add(clone);
    }
Ejemplo n.º 4
0
 void Awake()
 {
     playerAnim = GetComponent <Animator>();
     stats      = GetComponent <PlayerCreature>().stats;
     player     = GetComponent <Player>();
 }