Esempio n. 1
0
    public void RequestHealthbar(int instanceID, Transform trans, BattlerData data)
    {
        if (!IsCurrentlyActive(instanceID))
        {
            HealthbarController healthbar = _healthbarPoolSO.Request();
            _currentlyActiveHealthbars.Add(healthbar);

            healthbar.SetHealthbar(instanceID, trans, data);
            healthbar.OnHealthbarFinishedDisplaying += OnHealthbarFinishedPlaying;
        }
    }
 void Start()
 {
     //Preparation des variables
     animator    = GetComponent <Animator> ();
     cameraT     = Camera.main.transform;
     rb          = GetComponent <Rigidbody>();
     jump        = new Vector3(0.0f, 2.0f, 0.0f);
     audioSource = GetComponent <AudioSource>();
     healthbar   = GetComponentInChildren <HealthbarController> ();
     Health      = Mathf.Min(Health, maxHealth);
 }
Esempio n. 3
0
    protected void Start()
    {
        CurrentHealth = MaxHealth;

        if (this is MonsterController || this is WeaponController)
        {
            GameObject go = Instantiate <GameObject>(GameManager.Instance.HealthBarPrefab, this.transform);
            HealthBar = go.GetComponent <HealthbarController>();
            go.transform.localPosition = new Vector3(0, 0.25f, 0);
        }
    }
Esempio n. 4
0
 // Use this for initialization
 void Start()
 {
     assetsLib = GameObject.FindGameObjectWithTag("Assets").GetComponent <AssetsLibrary>();
     markBox   = gameObject.transform.GetChild(2).gameObject.GetComponent <SpriteRenderer>();
     trav      = GetComponent <TravelerController>();
     hpcon     = gameObject.transform.GetChild(1).gameObject.GetComponent <HealthbarController>();
     pinfo     = new PlayerInfo(2, hpcon);
     ec        = gameObject.GetComponent <EnemyControllerNew>();
     attTimer  = ec.pinfo.stats.attackCooldown;
     gi.ec.Add(ec);
 }
Esempio n. 5
0
    public void Rest()
    {
        HealthbarController hbController = healthbar_fg.GetComponent <HealthbarController>();
        Character           character    = player.GetComponent <Character>();

        character.curHP += character.maxHP / 4;
        hbController.onTakeDmg(-character.maxHP / 4);
        TurnOnMenu();
        GameHandler gh = gamehandler.GetComponent <GameHandler>();

        gh.actions = gh.maxturns;
    }
Esempio n. 6
0
    public void Skill()
    {
        if (reallyHasEnemy)
        {
            animator.SetFloat("moveX", -1);
            animator.SetFloat("moveY", 0);
            animator.SetBool("skill", true);
            skilling = true;
            //fight.SetActive(false);
            Debug.Log("Fighting");
            HealthbarController hbController = healthbar_fg.GetComponent <HealthbarController>();

            Character character = player.GetComponent <Character>();

            Monsters monster = enemy.GetComponent <Monsters>();
            if (character.curHP >= 0)
            {
                // Monsters monster = enemy.GetComponent<Monsters>();
                // Character character = player.GetComponent<Character>();
                CalculateDmgEnemy(monster);
                CalculateDmgPlayer(character);
                if (character.curHP - enemyDmg <= 0 || monster.curHP - playerDmg * 2 <= 0)
                {
                    animatorE.SetBool("attacking", false);

                    dialogActive = true;
                    TurnOffFight();
                    enemy.SetActive(false);
                    dialogActive = true;
                    dialogBox.SetActive(true);
                    dialog          = "You have defeated the log!";
                    dialogText.text = dialog;
                    turnFinished    = true;
                    afterFightN     = true;
                }
                else
                {
                    Debug.Log("player:" + playerDmg.ToString());
                    Debug.Log("enemy:" + enemyDmg.ToString());
                    monster.curHP   -= playerDmg * 2;
                    character.curMP -= 10;
                    character.curHP -= enemyDmg;
                    hbController.onTakeDmg(enemyDmg);

                    Debug.Log("player HP:" + character.curHP.ToString());
                    Debug.Log("enemy HP:" + monster.curHP.ToString());
                }
            }
        }
    }
Esempio n. 7
0
    private void hitEnemy()
    {
        if (target != null)
        {
            Transform           healthBarTransform = target.transform.Find("HealthBar");
            HealthbarController healthbar          = healthBarTransform.gameObject.GetComponent <HealthbarController>();

            Debug.Log("Reduce health!");
            healthbar.currentHealth -= Mathf.Max(damage, 0);

            if (healthbar.currentHealth <= 0)
            {
                EnemyDies();
            }
        }
    }
Esempio n. 8
0
    public PlayerInfo(int team, HealthbarController hpCon)
    {
        if (team == 1)
        {
            if (DataTransferManager.gameLoaded)
            {
                for (int i = 0; i < DataTransferManager.inv.items.Length; i++)
                {
                    items[i]    = DataTransferManager.inv.items[i];
                    skillPoints = DataTransferManager.dataHolder.skillPoints;
                }
            }
            if (!DataTransferManager.gameLoaded)
            {
                for (int i = 0; i < items.Length; i++)
                {
                    items[i] = new Item();
                }
            }
        }

        if (team == 2)
        {
            for (int i = 0; i < items.Length; i++)
            {
                items[i] = new Item();
            }
        }

        InstantiateAbilities();
        this.team  = team;
        this.hpCon = hpCon;
        this.name  = DataTransferManager.dataHolder.name;
        baseStats  = new BaseStats(team);
        PlayerInfo pinfo = this;

        hpCon.SetPlayerInfoRef(pinfo);

        InstantiatePassiveSkills();
        invStats = new EquipmentStats(items);
        stats    = new CompleteStats(baseStats, invStats, passiveSkills);
        SetStartingStats();
        InstantiateAbilities();
        AddHealingPots(5);
        AddManaPots(5);
        stats.RestoreHealth();
    }
Esempio n. 9
0
    // Start is called before the first frame update
    void Start()
    {
        if (hasEnemy)
        {
            animator  = player.GetComponent <Animator>();
            animatorE = enemy.GetComponent <Animator>();
        }

        if (hasEnemy)
        {
            HealthbarController hbController = healthbar_fg.GetComponent <HealthbarController>();

            Character character = player.GetComponent <Character>();
            hbController.maxHP  = character.maxHP;
            hbController.Health = character.curHP;
            hbController.onTakeDmg(0);
            print(hbController.Health.ToString());
        }
    }
Esempio n. 10
0
    public void InitializeData()
    {
        hpCon      = gameObject.transform.GetChild(1).gameObject.GetComponent <HealthbarController>();
        plrChar    = gameObject.transform.GetChild(0).gameObject;
        sword      = plrChar.transform.GetChild(0).gameObject;
        attcon     = sword.transform.GetChild(0).GetComponent <AttackControllerPlr>();
        spawner    = GameObject.FindGameObjectWithTag("Assets").GetComponent <Spawner>();
        anim       = gameObject.transform.GetChild(0).gameObject.GetComponent <AnimationManager>();
        pinfo.name = DataTransferManager.dataHolder.name;
        pinfo      = new PlayerInfo(1, hpCon);
        pinfo.SetStartingStats();

        RefreshPosAsInt(new Vector2Int(Mathf.RoundToInt(transform.position.x), Mathf.RoundToInt(transform.position.y)));
        MapDataController.map[pos.x, pos.y].SetNpc(pinfo);
        SetABC_ToAbilities(); //reference to action button group, for easier communication between buttons and abilities
        pinfo.dir = "";

        abc.pinfo = pinfo;
        acp.SetTimer();
    }
Esempio n. 11
0
    // Start is called before the first frame update
    private void Start()
    {
        defaultState = new PlayerIdle(this);
        animator     = GetComponent <Animator>();
        // New line
        levelSystem = new LevelSystem();
        levelWindow = GameObject.Find("GameplayCanvas/LevelWindow").GetComponent <LevelWindow>();
        levelWindow.SetLevelSystem(levelSystem);

        if (myState == null)
        {
            myState = defaultState;
            myState.Enter();
        }
        rb = GetComponent <Rigidbody>();
        dodgeAbility.dodgeDuration = -1f;
        MAX_STAMANA = data.remainingStamana;

        healthbar       = GameObject.Find("GameplayCanvas/HealthBar_BG").GetComponent <HealthbarController>();
        stamanaMeter    = GameObject.Find("GameplayCanvas/UIDiamonds/StamanaBar/StamanaBarForeground").GetComponent <Image>();
        skillTreeWindow = GameObject.Find("GameplayCanvas").GetComponent <SkillTreeWindow>();
    }
 // Use this for initialization
 void Start()
 {
     //State = State.BeforeCombat;
     animator  = GetComponent <Animator>();
     healthbar = GetComponentInChildren <HealthbarController>();
 }
Esempio n. 13
0
 private void OnHealthbarFinishedPlaying(HealthbarController healthbar)
 {
     healthbar.OnHealthbarFinishedDisplaying -= OnHealthbarFinishedPlaying;
     _currentlyActiveHealthbars.Remove(healthbar);
     this._healthbarPoolSO.Return(healthbar);
 }
Esempio n. 14
0
    // Update is called once per frame
    void Update()
    {
        if (enemyAttack)
        {
            enemyAttackTime -= 1;
            if (enemyAttackTime == 0)
            {
                animatorE.SetBool("attacking", false);
                enemyAttack     = false;
                enemyAttackTime = 60;
                TurnOnFight();
            }
        }
        if (wait && !afterFightN)
        {
            waitTime -= 1;
            if (waitTime == 0)
            {
                animatorE.SetBool("attacking", true);
                if (!afterFightN)
                {
                    enemyAttack = true;
                }

                waitTime = 30;
                wait     = false;
            }
        }
        if (attacking)
        {
            attackTime -= 1;
            //Debug.Log(attackTime);
            if (attackTime == 0)
            {
                //Debug.Log("whit");

                attacking = false;
                animator.SetBool("attacking", false);
                attackTime = 30;
                wait       = true;
            }
        }
        if (skilling)
        {
            skilltime -= 1;
            if (skilltime == 0)
            {
                //Debug.Log("whit");

                skilling = false;
                animator.SetBool("skill", false);
                skilltime = 20;
                wait      = true;
            }
        }
        if (player2In && !player.GetComponent <PlayerMovement>().moving&& parch)
        {
            HealthbarController hbController = healthbar_fg.GetComponent <HealthbarController>();

            Character character = player.GetComponent <Character>();
            hbController.maxHP  = character.maxHP;
            hbController.Health = character.curHP;
            hbController.onTakeDmg(0);
            print(hbController.Health.ToString());
            dialogActive = true;
            dialogBox.SetActive(true);
            dialog          = "You have encountered another player, get ready to rumble!";
            dialogText.text = dialog;
            parch           = false;
            beginFightP     = true;
            TurnOffMenu();
        }
        if (Input.GetMouseButton(0))
        {
            if (dialogActive)
            {
                TurnOnMenu();
                dialogActive = false;
                dialogBox.SetActive(false);
                if (!reallyHasEnemy)
                {
                    gamehandler.GetComponent <GameHandler>().sumActions();
                }
                if (reallyHasEnemy && !afterFightN)
                {
                    exlamation.SetActive(false);
                    enemy.SetActive(true);
                    TurnOffMenu();

                    /*if (currentHealth.initialValue > 0)
                     * {
                     *  currentHealth.initialValue -= 1;
                     *  playerHealthSignal.Raise();
                     * }*/
                }

                if (beginFightP)
                {
                    TurnOffMenu();
                    TurnOnFight();
                    Debug.Log("Fight wih user");
                }

                if (beginFightN)
                {
                    TurnOffMenu();
                    TurnOnFight();
                    beginFightN = false;
                    Debug.Log("Fight wih NPC");
                }

                if (afterFightN)
                {
                    //fight.SetActive(false);

                    TurnOnMenu();
                    TurnOffFight();
                    enemy.SetActive(false);
                    turnOnEndTurn();
                }
            }
        }
    }