Esempio n. 1
0
    public override bool AttackInDirection(Vector2 direction, bool regenMana = false)
    {
        if (timeToAttack <= 0 && (am == null || am.globalCDProgress >= am.globalCooldown))
        {
            if (animator)
            {
                animator.WeaponStrike();
            }

            // kreiranje projektila na mestu nosioca
            GameObject projectile = Instantiate(firePrefab);
            projectile.transform.position = transform.position;

            Transform target = autolock.GetClosest();

            PlayerWithJoystick player = parent.GetComponent <PlayerWithJoystick>();
            int bonusDamage           = (player ? player.GetDamage() : 0);

            // ispaljivanje projektila

            if (target)
            {
                projectile.GetComponent <FireProjectile>().Shoot(parent.transform, target, damage + bonusDamage, range, projectileSpeed, knockback, knockbackForce, regenMana);
            }
            else
            {
                projectile.GetComponent <FireProjectile>().Shoot(parent.transform, direction, damage + bonusDamage, range, projectileSpeed, knockback, knockbackForce, regenMana);
            }
            base.AttackInDirection(direction);

            return(true);
        }

        return(false);
    }
Esempio n. 2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        PlayerWithJoystick player = collision.GetComponent <PlayerWithJoystick>();

        if (player != null)
        {
            player.AddRotation(right ? angle : -angle);
        }
    }
Esempio n. 3
0
    protected virtual void OnTriggerExit2D(Collider2D collision)
    {
        PlayerWithJoystick player = collision.GetComponent <PlayerWithJoystick>();

        if (player && (interactable || canReactivate))
        {
            player.ActionChange(PlayerWithJoystick.ActionChangeType.SWAP_TO_WEAPON, transform);
        }
    }
Esempio n. 4
0
 protected override void updateVector2()
 {
     if (GameManager.joystick)
     {
         player  = GameManager.I.playerInstance as PlayerWithJoystick;
         vector2 = player.GetFacingDirection();
     }
     else
     {
         base.updateVector2();
     }
 }
Esempio n. 5
0
    public void AttackPointerDown(JoystickController joystick)
    {
        PlayerWithJoystick player = GameManager.I.playerInstance as PlayerWithJoystick;

        if (player.action == PlayerWithJoystick.ActionType.WEAPON)
        {
            joystick.transform.parent.GetComponent <CanvasGroup>().alpha = 1;
            GameManager.I.playerInstance.GetWeapon().StartHitting(joystick.InputDirection);
        }
        else
        {
            player.DoAction();
        }
    }
Esempio n. 6
0
    protected override void OnTriggerEnter2D(Collider2D collision)
    {
        base.OnTriggerEnter2D(collision);

        if (collision.GetComponent <AttackingCharacter>() == GameManager.I.playerInstance)
        {
            PlayerWithJoystick player = GameManager.I.playerInstance as PlayerWithJoystick;

            switch (type)
            {
            case PortalType.ENTRY:
                animator.SetTrigger("Deactivate");
                break;
            }
        }
    }
Esempio n. 7
0
    public void UpdateAbilityButtons()
    {
        PlayerWithJoystick player = parent as PlayerWithJoystick;

        int i = 0;

        foreach (Ability ability in abilities)
        {
            if (player.energy < ability.manaCost)
            {
                UIManager.I.DisableAbilityButton(i);
            }
            else
            {
                UIManager.I.EnableAbilityButton(i);
            }
            i++;
        }
    }
Esempio n. 8
0
    public void SaveGame()
    {
        print("Saving progress...");

        BinaryFormatter    bf     = new BinaryFormatter();
        FileStream         file   = File.Create(savePath);
        PlayerWithJoystick player = GameManager.I.playerInstance as PlayerWithJoystick;
        GameState          game   = new GameState();

        game.isRunStarted = GameManager.I.isRunStarted;
        game.gameMode     = GameManager.I.gameMode;
        game.gameLevel    = GameManager.I.currentLevel;
        game.coins        = GameManager.I.coins;
        game.attributes   = GameManager.I.attributes;
        game.abilities    = GameManager.I.abilities;
        game.activeQuests = QuestManager.I.GetQuestInfos();

        gameState = game;

        bf.Serialize(file, game);
        file.Close();
    }