Beispiel #1
0
    public PowerUp(Vector2 NewPosition, PowerupsSystem.POWERUP_TYPE NewPowerType = PowerupsSystem.POWERUP_TYPE.TOTAL_POWERUPS)
    {
        if (NewPowerType == PowerupsSystem.POWERUP_TYPE.TOTAL_POWERUPS)
        {
            //If there is no specified power type passed in, a random powerup is assigned
            powerType = (PowerupsSystem.POWERUP_TYPE)Random.Range(0, (float)PowerupsSystem.POWERUP_TYPE.TOTAL_POWERUPS);
        }
        else
        {
            powerType = NewPowerType;
        }

        powerupPosition = NewPosition;
    }
Beispiel #2
0
    public void AssignType(PowerupsSystem.POWERUP_TYPE NewPowerType = PowerupsSystem.POWERUP_TYPE.TOTAL_POWERUPS)
    {
        //NOTE: PowerUpTexture must be initialised before this function can be used!

        if (NewPowerType != PowerupsSystem.POWERUP_TYPE.TOTAL_POWERUPS)
        {
            powerType = NewPowerType;
        }

        switch (powerType)
        {
        case PowerupsSystem.POWERUP_TYPE.POWERUP_MOVESPEED:
        {
            //Unit stats modify
            AddedMoveSpeed        = 5;
            PowerUpTexture.sprite = moveSpeedSprite;
            break;
        }

        case PowerupsSystem.POWERUP_TYPE.POWERUP_ATTACKSPEED:
        {
            //Unit stats modify
            AddedAttackSpeed      = 0.5f;
            PowerUpTexture.sprite = attackSpeedSprite;
            break;
        }

        case PowerupsSystem.POWERUP_TYPE.POWERUP_ATTACKDAMAGE:
        {
            //Unit stats modify
            AddedAttackDamage     = 10;
            PowerUpTexture.sprite = attackDamageSprite;
            break;
        }

        default:
            break;
        }

        PowerUpTexture.enabled = true;

        Vector2 canvasLocalScale = GameObject.FindGameObjectWithTag("Canvas").transform.localScale;

        PowerUpTexture.rectTransform.sizeDelta = new Vector2(GridSystem.tileWidth * canvasLocalScale.x, GridSystem.tileHeight * canvasLocalScale.y);
    }