示例#1
0
        // Use this for initialization
        void Start()
        {
            m_animator = GetComponent <Animator>();


            // Reset Values
            prev_direction   = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
            prev_direction   = prev_direction.normalized;
            dirChanges       = 0;
            flippedCount     = 0;
            weaponSwings     = 0;
            explorationCount = 0;

            //Store player position to check how far player has moved to decrement food.
            previousPlayerPosition = transform.position;

            //Get the CaveGameManager component to edit food points data
            gameManager = GameObject.FindWithTag("GameManager").GetComponent <CaveGameManager>();
            food        = gameManager.playerFoodPoints;

            //foodDecrement = GameObject.FindWithTag("GameManager").GetComponent<AIFoodDecrement>().getFoodDecrement();
            foodDecrement = GameObject.FindWithTag("GameManager").GetComponent <AIFoodDecrementContinuous>().GetFoodDecrement();
            GameObject.FindWithTag("GameManager").GetComponent <ItemSpawn>().updateFoodPercent(GameObject.FindWithTag("GameManager").GetComponent <AIFoodCount>().GetFoodWeight());
            GameObject.FindWithTag("GameManager").GetComponent <ItemSpawn>().updateWeaponPercent(GameObject.FindWithTag("GameManager").GetComponent <AIWeaponCount>().GetWeaponWeight());
            // pointsPerFood = temps.Item2;

            canMove     = true;
            canAttack   = true;
            damage      = 10;
            weaponName  = "Weapon";
            enemyDamage = 50;
        }
        //Awake is always called before any Start functions
        void Awake()
        {
            //Check if instance already exists
            if (instance == null)
            {
                //if not, set instance to this
                instance = this;
            }            //If instance already exists and it's not this:
            else if (instance != this)
            {
                //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager.
                Destroy(gameObject);
            }
            //Sets this to not be destroyed when reloading scene
            DontDestroyOnLoad(gameObject);

            levelText  = GameObject.Find("LevelText").GetComponent <Text>();
            levelImage = GameObject.Find("LevelImage");
            player     = GameObject.Find("LightBandit").GetComponent <Bandit>();
            //Assign enemies to a new List of Enemy objects.
            enemies = new List <EnemyBuilder>();

            if (playerFoodPoints == null)
            {
                playerFoodPoints = 500;
            }
            //Get a component reference to the attached BoardManager script
            mapGenerator = GetComponent <MapGenerator>();

            //Call the InitGame function to initialize the first level
            //Debug.Log("Awake Init");
            InitGame();
        }
示例#3
0
        public void DecrementHealthFromPlayer()
        {
            CaveGameManager gameManager = GameObject.Find("MapGenerator").GetComponent <CaveGameManager>();

            if (gameManager.doingSetup == false)
            {
                //Reduce player health
                food -= enemyDamage;

                //Update the food display with the new total.
                foodText.text = "-" + enemyDamage + " Food: " + food;
                //Check to see if game has ended.
                CheckIfGameOver();
            }
        }
示例#4
0
        private void Restart()
        {
            //Load the next level
            CaveGameManager caveGameManager = GameObject.Find("MapGenerator").GetComponent <CaveGameManager>();

            //foodDecrement = GameObject.FindWithTag("GameManager").GetComponent<AIFoodDecrement>().getFoodDecrement();
            foodDecrement = GameObject.FindWithTag("GameManager").GetComponent <AIFoodDecrementContinuous>().GetFoodDecrement();
            GameObject.FindWithTag("GameManager").GetComponent <ItemSpawn>().updateFoodPercent(GameObject.FindWithTag("GameManager").GetComponent <AIFoodCount>().GetFoodWeight());
            GameObject.FindWithTag("GameManager").GetComponent <ItemSpawn>().updateWeaponPercent(GameObject.FindWithTag("GameManager").GetComponent <AIWeaponCount>().GetWeaponWeight());

            damageChange = GameObject.FindWithTag("GameManager").GetComponent <AIPlayerDamage>().GetDamageChange();
            damage      += damageChange;
            if (damage < 5)
            {
                damage = 5;
            }

            dirChanges   = 0;
            flippedCount = 0;
            weaponSwings = 0;
            caveGameManager.InitGame();
        }
示例#5
0
        private void Restart()
        {
            //Load the next level
            CaveGameManager caveGameManager = GameObject.Find("MapGenerator").GetComponent <CaveGameManager>();

            //foodDecrement = GameObject.FindWithTag("GameManager").GetComponent<AIFoodDecrement>().getFoodDecrement();
            foodDecrement = GameObject.FindWithTag("GameManager").GetComponent <AIFoodDecrementContinuous>().GetFoodDecrement();
            GameObject.FindWithTag("GameManager").GetComponent <ItemSpawn>().updateFoodPercent(GameObject.FindWithTag("GameManager").GetComponent <AIFoodCount>().GetFoodWeight());
            GameObject.FindWithTag("GameManager").GetComponent <ItemSpawn>().updateWeaponPercent(GameObject.FindWithTag("GameManager").GetComponent <AIWeaponCount>().GetWeaponWeight());

            damageChange = GameObject.FindWithTag("GameManager").GetComponent <AIPlayerDamage>().GetDamageChange(CaveGameManager.instance.GetLevel());
            damage      += damageChange;
            if (damage < 5)
            {
                damage = 5;
            }

            if (CaveGameManager.instance.GetLevel() >= 5 && CaveGameManager.instance.GetLevel() < 10)
            {
                //if (CaveGameManager.instance.GetLevel() == 6) firstKill = true;
                pointsPerFruit = 30;
                pointsPerDrink = 60;
                pointsPerVeg   = 45;
                pointsPerMeat  = 150;
                enemyDamage    = 150;
            }
            else if (CaveGameManager.instance.GetLevel() >= 10 && CaveGameManager.instance.GetLevel() < 15)
            {
                //if (CaveGameManager.instance.GetLevel() == 11) firstKill = true;
                pointsPerFruit = 150;
                pointsPerDrink = 300;
                pointsPerVeg   = 225;
                pointsPerMeat  = 600;
                enemyDamage    = 600;
            }
            else if (CaveGameManager.instance.GetLevel() >= 15 && CaveGameManager.instance.GetLevel() < 20)
            {
                //if (CaveGameManager.instance.GetLevel() == 16) firstKill = true;
                pointsPerFruit = 250;
                pointsPerDrink = 500;
                pointsPerVeg   = 375;
                pointsPerMeat  = 1000;
                enemyDamage    = 1000;
            }
            else if (CaveGameManager.instance.GetLevel() >= 20)
            {
                //if (CaveGameManager.instance.GetLevel() == 21) firstKill = true;
                pointsPerFruit = 1250;
                pointsPerDrink = 2500;
                pointsPerVeg   = 1875;
                pointsPerMeat  = 5000;
                enemyDamage    = 5000;
            }

            movementSpeed = GameObject.FindWithTag("GameManager").GetComponent <AIMovementSpeed>().GetSpeedChange();

            dirChanges   = 0;
            flippedCount = 0;
            weaponSwings = 0;
            firstKill    = false;
            caveGameManager.InitGame();
        }