private void Start()
    {
        playerInstance  = PlayerInstant.Instance;
        pickupAnimation = playerInstance.GetComponentInChildren <PickupAnimation>();

        gameObject.name = item.ToString();
        proportion      = GetComponentInChildren <SpriteRenderer>().transform.localScale.x;
    }
Example #2
0
    protected virtual void Start()
    {
        playerInstance = PlayerInstant.Instance;

        p_movementModel = playerInstance.GetComponent <CharacterMovementModel>();
        playerStats     = playerInstance.GetComponent <PlayerStats>();

        spawnCount = 0;

        enemyAction = basicAction;

        GetComponent <CircleCollider2D>().radius = 3f;
    }
    public void UsePickup()
    {
        PlayerStats      playerStats = PlayerInstant.Instance.transform.gameObject.GetComponent <PlayerStats>();
        AttackablePlayer attackable  = PlayerInstant.Instance.transform.gameObject.GetComponentInChildren <AttackablePlayer>();

        if (item == enumInventory.ProjectilePickup && playerStats.IsProjetileActive() == false)
        {
            playerStats.SetProjectile();
            DoNonInstantiateAnimation();
            ResetSelectedInventory();
            return;
        }

        if (item == enumInventory.HealthPickup && attackable.GetHealth() < attackable.GetMaxHealth())
        {
            attackable.RestoreFullHealth();
            DoNonInstantiateAnimation();
            ResetSelectedInventory();
            return;
        }

        if (item == enumInventory.SpeedPickup && playerStats.IsSpeedUp() == false)
        {
            playerStats.SpeedUp();
            DoNonInstantiateAnimation();
            ResetSelectedInventory();
            return;
        }

        if (item == enumInventory.StrengthPickup && playerStats.IsDamageUp() == false)
        {
            playerStats.DamageUp();
            DoNonInstantiateAnimation();
            ResetSelectedInventory();
            return;
        }

        if (item == enumInventory.SlimePickup)
        {
            playerInstance = PlayerInstant.Instance;

            tempInstantiateObject = playerInstance.transform.Find("PlayerSlime1").gameObject;
            CreatePlayerSlime(tempInstantiateObject);
            DoNonInstantiateAnimation();
            ResetSelectedInventory();
            return;
        }

        if (item == enumInventory.RangePickup && playerStats.IsRangeUp() == false)
        {
            playerStats.RangeUp();
            DoNonInstantiateAnimation();
            ResetSelectedInventory();
            return;
        }

        //if (item == enumInventory.InvisiblePickup && playerStats.IsInvisibleUp() == false)
        //{
        //    playerStats.InvisibleUp();
        //    DoNonInstantiateAnimation();
        //    ResetSelectedInventory();
        //    return;
        //}

        //if (item == enumInventory.InvinciblePickup && playerStats.IsInvincibleUp() == false)
        //{
        //    playerStats.InvincibleUp();
        //    DoNonInstantiateAnimation();
        //    ResetSelectedInventory();
        //    return;
        //}

        if (item == enumInventory.DecoyPickup)
        {
            playerInstance        = PlayerInstant.Instance;
            tempInstantiateObject = playerInstance.transform.Find("Decoy").gameObject;

            DoNonInstantiateAnimation();
            ResetSelectedInventory();
            CreateInstantiatePikcup();
            return;
        }

        //if (item == enumInventory.BombPickup)
        //{
        //    playerInstance = PlayerInstant.Instance;
        //    tempInstantiateObject = playerInstance.transform.Find("Bomb").gameObject;

        //    DoNonInstantiateAnimation();
        //    ResetSelectedInventory();
        //    CreateInstantiatePikcup();
        //    return;
        //}

        DoInventoryCancelAnimation();
    }
 private void ResetSelectedInventory()
 {
     playerInstance = PlayerInstant.Instance;
     playerInstance.transform.gameObject.GetComponent <PlayerInventory>().ResetSlected();
 }
 private void Awake()
 {
     Instance = this;
     Object   = gameObject;
 }