Esempio n. 1
0
 public void GetAndImplementrPerks()
 {
     perkSystem = GetComponent <PerkSystem>();
     for (int i = 0; i < perkSystem.perks.Count; i++)
     {
         perkSystem.perks[i].SetWeapons(RightWeapon, LeftWeapon);
         perkSystem.perks[i].SetPlayer(this);
         perkSystem.perks[i].ImplementPerk();
     }
 }
Esempio n. 2
0
 public static void LoadPerks()
 {
     if (savedData != null)
     {
         for (int i = 0; i < savedData["Perks"].Count; i++)
         {
             PerkSystem.AssignPerk(savedData["Perks"][i]["ID"].ToString(), (int)savedData["Perks"][i]["Level"]);
         }
     }
 }
Esempio n. 3
0
 void Start()
 {
     perkSystem  = GameObject.FindGameObjectWithTag("Player").GetComponent <PerkSystem>();
     audioSource = GetComponent <AudioSource>();
     selfbody    = GetComponent <Rigidbody>();
     State       = EnemyState.Attacking; // Initial state
     if (GameObject.FindWithTag("Player"))
     {
         playerTransform = GameObject.FindWithTag("Player").GetComponent <Transform>();
         playerRigidbody = GameObject.FindWithTag("Player").GetComponent <Rigidbody>();
     }
     else
     {
         Debug.Log("Can't find player gameobject, is player tagged or placed in scene?");
     }
     GameManager.instance.BossHealthBarSetup(health);
 }
Esempio n. 4
0
	void Start()
	{
		/*
		// initialize the weapons
		*/
		for ( int i = 0; i < weapons.Count; ++i )
		{
			// re-assigning the GameObject is import because Instantiate() creates a clone
			// when switching weapons, we need to get the Weapon component of the correct object (the clone)
			weapons[i] = Instantiate( weapons[i] ) as GameObject;
			InitializeWeapon( GetWeapon( i ) );

			// the weapon prefabs don't default to hitting enemies (only scenery),
			// so add it to their list of targets.
			weapons[i].GetComponent<DamageSystem>().targets.Add( "Enemy" );
		}

		/*
		// set the default weapon
		*/
		_defaultWeapon = GetWeapon( 0 );

		// we must insure the deafult weapon is not null
		// if it is, we create a blank weapon to prevent future errors
		if ( _defaultWeapon == null )
		{
			GameObject weaponObject = new GameObject();
			weaponObject.SetActive( false );

			Weapon weapon = weaponObject.AddComponent<Weapon>();
			_defaultWeapon = InitializeWeapon( weapon );
		}

		/*
		// set the current weapon
		*/

		SwitchWeapon( 0 );

		_perkSystem = GetComponent<PerkSystem>();

		_fireRateMod = 0.0f;
		_damageMod = 0.0f;
	}
Esempio n. 5
0
    void Start()
    {
        /*
         * // initialize the weapons
         */
        for (int i = 0; i < weapons.Count; ++i)
        {
            // re-assigning the GameObject is import because Instantiate() creates a clone
            // when switching weapons, we need to get the Weapon component of the correct object (the clone)
            weapons[i] = Instantiate(weapons[i]) as GameObject;
            InitializeWeapon(GetWeapon(i));

            // the weapon prefabs don't default to hitting enemies (only scenery),
            // so add it to their list of targets.
            weapons[i].GetComponent <DamageSystem>().targets.Add("Enemy");
        }

        /*
         * // set the default weapon
         */
        _defaultWeapon = GetWeapon(0);

        // we must insure the deafult weapon is not null
        // if it is, we create a blank weapon to prevent future errors
        if (_defaultWeapon == null)
        {
            GameObject weaponObject = new GameObject();
            weaponObject.SetActive(false);

            Weapon weapon = weaponObject.AddComponent <Weapon>();
            _defaultWeapon = InitializeWeapon(weapon);
        }

        /*
         * // set the current weapon
         */

        SwitchWeapon(0);

        _perkSystem = GetComponent <PerkSystem>();

        _fireRateMod = 0.0f;
        _damageMod   = 0.0f;
    }
Esempio n. 6
0
    void Start()
    {
        perkSystem  = GameObject.FindGameObjectWithTag("Player").GetComponent <PerkSystem>();
        audioSource = GetComponent <AudioSource>();
        selfbody    = GetComponent <Rigidbody>();
        State       = EnemyState.Chasing; // Initial state
        if (GameObject.FindWithTag("Player"))
        {
            playerTransform = GameObject.FindWithTag("Player").GetComponent <Transform>();
            playerRigidbody = GameObject.FindWithTag("Player").GetComponent <Rigidbody>();
        }
        else
        {
            Debug.Log("Can't find player gameobject, is player tagged or placed in scene?");
        }

        agent            = GetComponent <NavMeshAgent>();
        Speed            = agent.speed; // Gets the speed value of the navmesh agent
        baseAcceleration = agent.acceleration;
        GameManager.instance.BossHealthBarSetup(health);
    }
Esempio n. 7
0
    private void OnEnable()
    {
        gameObject.transform.GetChild(2).GetComponent <ExplosiveBolt>();
        perkSystem       = GameObject.FindGameObjectWithTag("Player").GetComponent <PerkSystem>();
        playerController = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>();

        if (perkSystem.FireProjectiles == true)
        {
            gameObject.transform.GetChild(1).gameObject.SetActive(true);
        }

        if (perkSystem.ExplosiveProjectiles == true)
        {
            gameObject.transform.GetChild(2).gameObject.SetActive(true);
        }

        damage = playerController.GetDamage();

        if (damage > playerController.baseDamage)
        //if() needs work
        {
            isCrit = true;
        }

        else
        {
            isCrit = false;
        }

        if (isCrit == true)
        {
            gameObject.transform.GetChild(3).gameObject.SetActive(true);
        }

        else
        {
            gameObject.transform.GetChild(3).gameObject.SetActive(false);
        }
    }
Esempio n. 8
0
    void Start()
    {
        player      = GameObject.Find("RigidPlayer");
        perkSystem  = GameObject.FindGameObjectWithTag("Player").GetComponent <PerkSystem>();
        audioSource = GetComponent <AudioSource>();
        baseRoamingDetectionRadius = roamingDetectionRadius;
        selfbody = GetComponent <Rigidbody>();
        State    = EnemyState.Positioning; // Initial state
        if (GameObject.FindWithTag("Player"))
        {
            playerTransform = GameObject.FindWithTag("Player").GetComponent <Transform>();
            playerRigidbody = GameObject.FindWithTag("Player").GetComponent <Rigidbody>();
        }
        else
        {
            Debug.Log("Can't find player gameobject, is player tagged or placed in scene?");
        }

        timer = Random.Range(0.5f, roamingMaxIdleTime); // Sets the timer randomly for the enemy so they seem more unique and dont all move at the same time.
        agent = GetComponent <NavMeshAgent>();
        Speed = agent.speed;                            // Gets the speed value of the navmesh agent
    }
Esempio n. 9
0
 public void Initialize(GameManager gameManager)
 {
     this.gameManager = gameManager;
     perkSystem       = gameManager.playerObject.GetComponent <Creature>().PerkSystem;
 }
Esempio n. 10
0
    // Update is called once per frame
    void Update()
    {
        if (perkSystem == null)
        {
            perkSystem = GameObject.FindGameObjectWithTag("Player").GetComponent <PerkSystem>();
        }

        if (Player == null)
        {
            Player = GameObject.FindGameObjectWithTag("Player");
        }

        if (mouseLook == null)
        {
            mouseLook = GameObject.FindGameObjectWithTag("Player").GetComponent <MouseLook>();
        }

        if (pausedGame == true)
        {
            mouseSensitivityNumber.text = "" + (int)(mouseSensitivity.value * 10f) / 10f;
        }

        if (playerController == null)
        {
            playerController = Player.GetComponent <PlayerController>();
        }
        if (BossActive == true) //BossHealthBar Updater
        {
            BossHealthHolder.SetActive(true);
            float BossPercentage = BossHp / BossMaxHp;
            BossHealthBar.fillAmount = BossPercentage;
            Debug.Log("% " + BossPercentage);
            Debug.Log("cur " + BossHp);
            Debug.Log("Max " + BossMaxHp);
            if (BossHp <= 0)
            {
                BossHealthHolder.SetActive(false);
            }
        }
        if (Input.GetKeyDown(KeyCode.Alpha0))
        {
            LevelUp();
        }
        float currentHealthPercentage = (float)playerController.health / (float)playerController.healthMax;

        healthBar.fillAmount = currentHealthPercentage;
        healthText.text      = "Health: " + playerController.health + " / " + playerController.healthMax;

        float currentArmorPercentage = (float)playerController.armor / (float)playerController.armorMax;

        armorBar.fillAmount = currentArmorPercentage;
        armorText.text      = "Armor: " + playerController.armor + " / " + playerController.armorMax;

        //float currentStaminaPercentage = playerController.stamina / playerController.staminaMax;
        //staminaBar.fillAmount = currentStaminaPercentage;
        //staminaText.text = "Stamina: " + (int)playerController.stamina + " / " + playerController.staminaMax;

        //float currentExperiencePercentage = playerController.experience / playerController.experienceMax;
        //experienceBar.fillAmount = currentExperiencePercentage;
        //experienceText.text = "Experience: " + playerController.experience + " / " + playerController.experienceMax;

        if (playerController.reloading == true)
        {
            reload.SetActive(true);
            reloading.fillAmount += 1f / playerController.reloadSpeed * Time.deltaTime;
            reloadTime.text       = "" + Mathf.Round((playerController.reloadSpeed - reloading.fillAmount * playerController.reloadSpeed) * 10f) / 10f;
        }

        ammoCount.text = "Ammo: " + playerController.ammo + " / " + playerController.ammoMax;

        if (PlayerPosition == null)
        {
            PlayerPosition = GameObject.FindGameObjectWithTag("Player").transform;
        }

        timer += Time.deltaTime;         // Used by regen.

        if (Input.GetKeyDown(KeyCode.P)) // Used for pausing the game
        {
            if (pausedGame == false)
            {
                if (Cursor.lockState == CursorLockMode.Locked)
                {
                    Cursor.lockState = CursorLockMode.None;
                }
                pauseMenu();
            }
            else
            {
                continueGame();
                closeSettingsMenu();
            }
        }
        if (Input.GetKeyDown(KeyCode.Backspace))
        {
            restartGame();
        }

        if (playerController.health <= 0 && isDead == false)
        {
            PlayerDeath();
            isDead = true;
            //restartGame();
        }
        if (recentlyDamaged == false) // If player is damaged and has not taken damage in a moment they regenerate.
        {
            /*if (timer > 0.2f && playerHealth < 100)
             * {
             *  //playerHealth += 1;
             *  colorFade += 1f;
             *  timer = 0;
             * }
             * else if (timer > 0.2f && colorFade < 100)
             * {
             *  colorFade += 1f;
             *  timer = 0;
             * }*/
        }

        //damaged.GetComponent<Image>().color = Color.Lerp(dmgColor, noColor,colorFade / 100);
        //ammoCount.text = collectiblesCollected.ToString();
    }