void Awake()
 {
     if (instance != null)
     {
         return;
     }
     instance = this;
     Forced   = false;
 }
Exemple #2
0
    public void SavePlayerData(PlayerStatsController statsController)
    {
        PlayerSaveData  playerData = new PlayerSaveData(statsController);
        BinaryFormatter formatter  = new BinaryFormatter();
        Stream          stream     = new FileStream(string.Concat(Application.persistentDataPath, playerDataSavePath), FileMode.Create, FileAccess.Write);

        formatter.Serialize(stream, playerData);
        stream.Close();
    }
Exemple #3
0
 void OnCollisionStay2D(Collision2D target)      // Dano
 {
     if (target.collider.tag == "Player" && PlayerPrefs.GetFloat(PlayerStatsController.CurrentSave() + "currentHP") > 0 && contador > 0.5f)
     {
         PlayerStatsController.TakeDamage(basicStats.baseAttack);
         AudioSource.PlayClipAtPoint(somDano, player.position);
         contador = 0;
     }
 }
Exemple #4
0
    public void ShowButtons()
    {
        bool hasToShowButton = PlayerStatsController.GetAttributsPoints() > 0;

        buttonAddConcentration.SetActive(hasToShowButton);
        buttonAddComunication.SetActive(hasToShowButton);
        buttonAddPrecision.SetActive(hasToShowButton);
        buttonAddReflex.SetActive(hasToShowButton);
    }
Exemple #5
0
    // Start is called before the first frame update
    protected void Start()
    {
        base.Start();
        currentLevel = PlayerStatsController.GetCurrentLevel();
        type         = PlayerStatsController.GetTypeCharacter();

        basicStats = PlayerStatsController.instance.GetBasicsStats(type);

        animationController = GetComponent <AnimationController>();
    }
Exemple #6
0
 private void Awake()
 {
     Animator              = GetComponent <Animator>();
     PowerUpController     = GetComponent <PowerUpController>();
     Renderer              = GetComponent <Renderer>();
     PlayerHealthManager   = GetComponent <PlayerHealthManager>();
     PlayerStateMachine    = GetComponent <PlayerStateMachine>();
     PowerUpActivator      = GetComponent <PowerUpActivator>();
     PlayerStatsController = GetComponent <PlayerStatsController>();
 }
 public void FinalizarMissao()
 {
     this.gameObject.SetActive(true);
     missaoAtiva = false;
     i           = 0;
     //Spawn.GetComponent<SpawnEsqueleto>().missaoDrop = false;
     PlayerStatsController.AddReputation(20);
     player.SetNivelDeMissao("missao2");
     texto.text = " ";
 }
Exemple #8
0
 private void Awake()
 {
     if (instance != null)
     {
         Debug.LogWarning("There is more than one instance of PlayerStatsController in the scene.");
         return;
     }
     instance   = this;
     fadeSystem = GameObject.FindGameObjectWithTag("FadeSystem").GetComponent <Animator>();
 }
 public void TextUpdateStatus()
 {
     pontos.text          = player.currentPontos.ToString();
     StatusTotais[0].text = player.danoTotal.ToString();
     StatusTotais[1].text = player.defTotal.ToString();
     StatusTotais[2].text = player.totalStamina.ToString();
     StatusTotais[3].text = player.totalLife.ToString();
     StatusTotais[4].text = PlayerStatsController.GetCurrentLevel().ToString();
     StatusTotais[5].text = PlayerStatsController.GetCurrentReputation().ToString();
 }
    void OnShoot()
    {
        PlayerStatsController playerStatsController = m_ProjectileBase.owner.GetComponent <PlayerStatsController>();

        DebugUtility.HandleErrorIfNullGetComponent <PlayerStatsController, ProdigyUltimateSpell>(playerStatsController, this, gameObject);

        playerStatsController.cdr.AddTemporaryModifier(cdr, duration);
        playerStatsController.moveSpeed.AddTemporaryModifier(speed, duration);
        playerStatsController.moveSpeed.AddTemporaryModifier(speedBoost, speedBoostDuration);
    }
    public PlayerSaveData(PlayerStatsController playerStatsController)
    {
        playerInventory           = playerStatsController.inventory_SO.inventory;
        equipmentsInventory       = playerStatsController.equipments_SO.inventory;
        dynamicAttributeContainer = playerStatsController.dynamicContainer;

        lastCheckPoint    = new float[3];
        lastCheckPoint[0] = SaveManager.Instance.lastCheckPointPosition.x;
        lastCheckPoint[1] = SaveManager.Instance.lastCheckPointPosition.y;
        lastCheckPoint[2] = SaveManager.Instance.lastCheckPointPosition.z;
    }
 public override void DestroiMonster()
 {
     if (currentLife <= 0)
     {
         PlayerStatsController.AddXp(xp);
         DropItem();
         treinador         = FindObjectOfType(typeof(TreinadorCampo)) as TreinadorCampo;
         treinador.missao1 = false;
         Destroy(this.gameObject);
     }
 }
Exemple #13
0
		// Barras da tela -------------------------------------------------------------------------------

	
		void OnGUI () {
		
			
		GUI.skin = Text;
		int LVL = PlayerPrefs.GetInt (PlayerStatsController.CurrentSave ()+"currentLevel");
		GUI.Box (new Rect(0, 3, 50 ,30), "LVL:"+ LVL.ToString("f0"));
		
		GUI.skin = Text;
		GUI.Box (new Rect(50, 3, 200 ,30), "HP:"+PlayerPrefs.GetFloat (PlayerStatsController.CurrentSave ()+"currentHP").ToString("f0") + "/" + PlayerPrefs.GetFloat (PlayerStatsController.CurrentSave ()+"maxHP").ToString("f0"));
		
		GUI.skin = HpBar;
		GUI.Box (new Rect(50, 3, 200 * (PlayerPrefs.GetFloat (PlayerStatsController.CurrentSave ()+"currentHP") / PlayerPrefs.GetFloat (PlayerStatsController.CurrentSave ()+"maxHP")) ,30), " ");
		
		GUI.skin = Text;
		GUI.Box (new Rect(50, 33, 200 ,20), "MP:"+PlayerPrefs.GetFloat (PlayerStatsController.CurrentSave ()+"currentMP").ToString("f0") + "/" + PlayerPrefs.GetFloat (PlayerStatsController.CurrentSave ()+"maxMP").ToString("f0"));
		
		GUI.skin = MpBar;
		GUI.Box (new Rect(50, 33, 200 * (PlayerPrefs.GetFloat (PlayerStatsController.CurrentSave ()+"currentMP") / PlayerPrefs.GetFloat (PlayerStatsController.CurrentSave ()+"maxMP")) ,20), " ");
		
		GUI.skin = Text;
		float xp = PlayerPrefs.GetFloat (PlayerStatsController.CurrentSave ()+"currentXP");
		float maxxp = PlayerPrefs.GetFloat (PlayerStatsController.CurrentSave ()+"maxXP");
		float tamanho;
		GUI.Box (new Rect(50, 53, 100 ,20), "XP:"+xp.ToString("f0") + "/" + maxxp.ToString("f0"));
		
		GUI.skin = XpBar;
		if (maxxp == 0) {
			tamanho = 100;
		} else {
			tamanho = 100*(xp / maxxp);
			if ( tamanho > 100 )
				tamanho = 100;
		}
		GUI.Box (new Rect(50, 53, tamanho,20), " ");
		GUI.skin = Text;
		GUI.Box (new Rect (Screen.width - Screen.width/3, Screen.height - 50, Screen.width/3, 50), PlayerPrefs.GetString (PlayerStatsController.CurrentSave ()+"nome"));

		GUI.Label (new Rect (0,0,Screen.width,Screen.height),hud);
		GUI.skin = Button;
		if (GUI.Button (new Rect (Screen.width - 100, 0, 100, 30), "Pause"))
						PauseGame.pause = !PauseGame.pause;
		if (GUI.Button (new Rect (Screen.width - 200, 0, 100, 30), "Attributes")) {
						currentSTR = 0;
						currentDEX = 0;
						currentINT = 0;
						currentVIT = 0;
						currentAP = PlayerPrefs.GetInt (PlayerStatsController.CurrentSave () + "currentAP");
						atributos = !atributos;
				}
		if (atributos)
						windowRect = GUI.Window (0, windowRect, Attributes, "Character Attributes");
	}
Exemple #14
0
 private void Awake()
 {
     if (ps == null)
     {
         ps = this;
     }
     else
     {
         Debug.LogWarning("PlayerStatsController destroyed");
         Destroy(ps);
     }
     DontDestroyOnLoad(gameObject);
 }
Exemple #15
0
    private void Awake()
    {
        Instance = this;

        rb2d       = GetComponent <Rigidbody2D> ();
        stats      = GetComponent <PlayerStatsController>();
        anim       = GetComponent <Animator>();
        controller = GetComponent <CharacterController2D>();

        sortingLayer = bodyParts[0].GetComponent <SpriteMeshInstance>().sortingLayerName;

        initialization();
    }
Exemple #16
0
    void Update()
    {
        Destroyer();

        /*if (Input.GetKeyDown(KeyCode.K))
         * {
         *  currentLife -= Random.Range(1, 10);
         * }*/
        UI.SetExperiencia(PlayerStatsController.GetNextXp(), PlayerStatsController.GetCurrentXp());
        UI.SetLife(totalLife, currentLife);
        UI.SetStamina(totalStamina, currentStamina);
        //base.Update();
    }
 public void ApplayDamage(int damage)
 {
     currentLife -= damage;
     if (currentLife <= 0)
     {
         OnDestroyed();
     }
     if (PlayerStatsController.GetCurrentReputation() <= -20)
     {
         Destroy(this.gameObject);
         destructive.gameObject.SetActive(true);
     }
 }
    // Use this for initialization
    void Start()
    {
        //RESET PLAYER PREFS;

        /*
         * PlayerPrefs.SetFloat("currentXp", 0);
         * PlayerPrefs.SetInt("currentLevel", 0);
         * PlayerPrefs.SetInt("pontosSkill", 0);
         * PlayerPrefs.SetInt("Reputação", 0);
         */
        instance = this;
        DontDestroyOnLoad(gameObject);
        Application.LoadLevel("GamePlay"); //Chama a cena apoós o menu
    }
    private void CreateAttack()
    {
        PlayerStatsController  targetStatsController = target.gameObject.GetComponent <PlayerStatsController>();
        PlayerAttackController targetAttackHandler   = target.gameObject.GetComponent <PlayerAttackController>();

        if (targetStatsController == null || targetAttackHandler == null)
        {
            return;
        }

        Attack attack = arrowShootingDefinition.EnemyCreateAttack(shooterStatsController, targetStatsController, arrowShootingDefinition.hitBackForce);

        targetAttackHandler.OnAttacked(this.gameObject, attack);
    }
Exemple #20
0
 //perguntar pro rodrigo como fazer escolha da classe do player por 1 método só
 public void SetPlayerType(int aux)
 {
     if (aux == 1)
     {
         PlayerStatsController.SetTyperCharacter(TypeCharacter.Killer);
         type       = PlayerStatsController.GetTypeCharacter();
         basicStats = PlayerStatsController.instance.GetBasicStats(type);
     }
     else if (aux == 2)
     {
         PlayerStatsController.SetTyperCharacter(TypeCharacter.Achiever);
         type       = PlayerStatsController.GetTypeCharacter();
         basicStats = PlayerStatsController.instance.GetBasicStats(type);
     }
 }
Exemple #21
0
        public async void Test_Index_PlayerStats()
        {
            //Arrange
            var db = DbSource.CreateDbSource();
            var c  = new PlayerStatsController(db);

            //Act
            var r = await c.Index();

            //Assert
            var result = Assert.IsType <ViewResult>(r);
            var model  = Assert.IsAssignableFrom <List <PlayerStats> >(result.ViewData.Model);

            Assert.Equal(1, model.Count());
        }
Exemple #22
0
        void Awake()
        {
            Titles = new List <TextMeshProUGUI>();
            Texts  = new List <TextMeshProUGUI>();
            var Player = GameObject.FindGameObjectWithTag("Player");

            PlayerPowerUpController = Player.GetComponent <PowerUpController>();
            PlayerStatsController   = Player.GetComponent <PlayerStatsController>();

            for (var i = 0; i < 4; i++)
            {
                Titles.Add(TitleTextObjects[i].GetComponent <TextMeshProUGUI>());
                Texts.Add(MainTextObjects[i].GetComponent <TextMeshProUGUI>());
            }
        }
    public Attack PlayerCreateAttack(PlayerStatsController attackerStats, EnemyStatsController defenderStats, Vector2 hitBackForce)
    {
        float coreDamage = attackerStats.GetAttackStat();

        coreDamage += Random.Range(plusDamage.x, plusDamage.y);

        bool isCritical = Random.value < criticalChange;

        if (isCritical)
        {
            coreDamage += criticalMultiplier;
        }

        return(new Attack((int)coreDamage, isCritical, hitBackForce));
    }
Exemple #24
0
    private void Start()
    {
        playerAnim         = GetComponent <Animator>();
        playerInputHandler = GetComponent <PlayerInputHandler>();
        rigid            = GetComponent <Rigidbody2D>();
        attackController = GetComponent <PlayerAttackController>();

        playerStateMachine.InitializeStartState(playerIdleState);
        statsController = GetComponent <PlayerStatsController>();

        isFacingRight = true;
        attackController.OnAttackedDirectionEvent.AddListener(HandleOnAttackedDirectionEvent);
        statsController.OnPlayerAttackedEvent.AddListener(HandleOnAttackedEvent);
        statsController.OnPlayerDeathEvent.AddListener(HandleOnDeathEvent);
    }
Exemple #25
0
    IEnumerator PrepareCombat()
    {
        ToggleButtons(false);
        GameObject playerGameObject = Instantiate(playerPrefab, playerBattleStation);

        playerUnit = playerGameObject.GetComponent <PlayerStatsController>();

        healthText.text      = "Health: " + playerUnit.currentHealth + "/" + playerUnit.maxHealth;
        energyTokenText.text = "Energy: " + playerUnit.currentEnergyTokens + "/" + playerUnit.maxEnergyTokens;
        dialoguePanel.GetComponentInChildren <Text>().text = enemyUnit.enemyEncounterLine;

        yield return(new WaitForSeconds(2f));

        state = CombatState.PLAYERTURN;
        PlayerTurn();
    }
Exemple #26
0
    // Update is called once per frame
    void Update()
    {
        AbrirStatusPontos();
        ContadorDeTempo += 1;
        if (ContadorDeTempo < tempoLoad && ativo)
        {
            inventario.gameObject.SetActive(!inventario.gameObject.activeSelf); // liga e desliga o inventario

            inventarioDoVendedor.gameObject.SetActive(false);
            ativo = false;
            Destroy(destruction.gameObject);
        }
        if (Input.GetKeyDown(KeyCode.I) && !inventarioDoVendedor.activeSelf)
        {
            miniMapa.gameObject.SetActive(!miniMapa.gameObject.activeSelf);
            HUD.gameObject.SetActive(!HUD.gameObject.activeSelf);
            TexTMissao.gameObject.SetActive(!TexTMissao.gameObject.activeSelf);
            inventario.gameObject.SetActive(!inventario.gameObject.activeSelf); // liga e desliga o inventario
            if (inventario.gameObject.activeSelf)                               //CONDICIONAL QUE PAUSE O GAME.
            {
                Time.timeScale = 0;
            }
            else
            {
                Time.timeScale = defaultTimeScale;
            }
        }
        if (messageItemToTake.gameObject.activeSelf)
        {
            currentTimeToShowMessage += Time.deltaTime;
            if (currentTimeToShowMessage > timeToShowMessage)
            {
                messageItemToTake.gameObject.SetActive(false);
            }
        }

        if (Input.GetKeyDown(KeyCode.Escape) && inventario.gameObject.activeSelf && !inventarioDoVendedor.activeSelf && !pause)
        {
            inventario.gameObject.SetActive(!inventario.gameObject.activeSelf); // liga e desliga o inventario
            Time.timeScale = defaultTimeScale;
        }
        testaPotion();

        nivel.text = PlayerPrefs.GetInt("currentLevel").ToString();
        SetReputation(100, PlayerStatsController.GetCurrentReputation());
    }
 /// <summary>
 /// Completes the task if all parts are completed. Starts the next task otherwise.
 /// </summary>
 public override void Complete()
 {
     // keep going if all puzzles in the task aren't completed
     if (puzzles.Count(e => e.IsComplete == false) > 0)
     {
         StartTask();
     }
     else
     {
         foreach (GameObject taskParticipant in taskParticipants)
         {
             PlayerStatsController playerStats = taskParticipant.GetComponent <PlayerStatsController>();
             playerStats.onDeath.RemoveListener(PlayerDied);
         }
         base.Complete();
     }
 }
    public IEnumerator PlayerCombat_MeleePlayerCanDamageEnemyWithPrimaryAndSecondaryAttacks()
    {
        GameObject            meleePlayer      = Object.Instantiate(TestResourceManager.Instance.GetResource("Melee Player"), Vector3.zero, Quaternion.identity);
        PlayerStatsController meleePlayerStats = meleePlayer.GetComponent <PlayerStatsController>();
        GameObject            enemy            = Object.Instantiate(TestResourceManager.Instance.GetResource("Enemy"), Vector3.zero, Quaternion.identity);
        EnemyStatsController  enemyStats       = enemy.GetComponent <EnemyStatsController>();

        Vector3 attackPos = new Vector3(0, 0, -2.5f);

        meleePlayer.SetActive(true);
        enemy.SetActive(true);

        var input = meleePlayer.GetComponent <PlayerInput>();

        input.enabled = true;

        _inputMock.SetInputToMockGamepad(input);

        meleePlayer.transform.position = attackPos;

        float initialHealth = enemyStats.health.CurrentValue;

        enemyStats.characterColour = meleePlayerStats.characterColour;

        yield return(new WaitForSeconds(0.5f));

        // Player attacks with primary attack
        _inputMock.Press(_inputMock.Gamepad.rightShoulder);
        yield return(new WaitForSeconds(1f));

        _inputMock.Release(_inputMock.Gamepad.rightShoulder);
        yield return(new WaitForSeconds(1f));

        Assert.Less(enemyStats.health.CurrentValue, initialHealth, "Melee player was unable to damage the enemy with primary attack!");

        initialHealth = enemyStats.health.CurrentValue;

        // Player attacks with secondary attack
        _inputMock.Press(_inputMock.Gamepad.rightTrigger);
        yield return(new WaitForSeconds(1f));

        _inputMock.Release(_inputMock.Gamepad.rightTrigger);
        yield return(new WaitForSeconds(1f));

        Assert.Less(enemyStats.health.CurrentValue, initialHealth, "Melee player was unable to damage the enemy with secondary attack!");
    }
Exemple #29
0
	public void SaveAP () {
		int str = PlayerPrefs.GetInt (PlayerStatsController.CurrentSave () + "STR");
		int dex = PlayerPrefs.GetInt (PlayerStatsController.CurrentSave () + "DEX");
		int inte = PlayerPrefs.GetInt (PlayerStatsController.CurrentSave () + "INT");
		int vit = PlayerPrefs.GetInt (PlayerStatsController.CurrentSave () + "VIT");
		float currentMaxHP = PlayerPrefs.GetFloat(PlayerStatsController.CurrentSave ()+"maxHP");
		float currentMaxMP = PlayerPrefs.GetFloat(PlayerStatsController.CurrentSave ()+"maxMP");
		PlayerPrefs.SetInt (PlayerStatsController.CurrentSave () + "STR", currentSTR + str);
		PlayerPrefs.SetInt (PlayerStatsController.CurrentSave () + "DEX", currentDEX + dex);
		PlayerPrefs.SetInt (PlayerStatsController.CurrentSave () + "INT", currentINT + inte);
		PlayerPrefs.SetInt (PlayerStatsController.CurrentSave () + "VIT", currentVIT + vit);
		PlayerPrefs.SetFloat (PlayerStatsController.CurrentSave () + "maxHP", currentMaxHP + (float)currentVIT * basicStats.startHP);
		PlayerPrefs.SetFloat (PlayerStatsController.CurrentSave () + "maxMP", currentMaxMP + (float)currentINT * basicStats.startMP);
		currentSTR = 0;
		currentDEX = 0;
		currentINT = 0;
		currentVIT = 0;
	}
    public override void DropItem()
    {
        PlayerStatsController.AddXp(xp);
        int random = Random.Range(1, 10);

        if (random == 2) //10% chance de acertar o valor
        {
            GameObject calcaInstanciada = Instantiate(calca, new Vector3(player.transform.position.x, player.transform.position.y, -1), Quaternion.identity);
            calcaInstanciada.GetComponent <CalçaGuerreiro>().GerarAleatorio(player.GetNivelDeMissao("missão1") + 1);
        }
        int randomico = Random.Range(1, 10);

        if (randomico == 1) //10% chance de acertar o valor
        {
            GameObject luvaInstanciada = Instantiate(luva, new Vector3(player.transform.position.x, player.transform.position.y, -1), Quaternion.identity);
            luvaInstanciada.GetComponent <LuvaGuerreiro>().GerarAleatorio(player.GetNivelDeMissao("missão1") + 1);
        }
        base.DropItem();
    }