Ejemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        startTime = Time.time;
        distance  = Vector2.Distance(startPosition, targetPosition);
        GameObject gm = GameObject.Find("GameManager");

        gameManager = gm.GetComponent <GameManagerBehavior>();

        switch (bulletTag)
        {
        case "Antibiotic":                //if the bulletTag is antibiotic
            bacteriaPenalty    = 0;       //0% penalty on bacteria
            virusPenalty       = 100;     //100% penalty on virus (means no damage)
            bacteriaResPenalty = 80;      //80% penalty on drug resistant bacteria (20% damage)
            break;

        case "Water":                     //if the bulletTag is water
            bacteriaPenalty    = 80;      //80% penalty on bacteria (20% damage)
            virusPenalty       = 0;       //0% penalty on virus
            bacteriaResPenalty = 0;       //0% penalty on drug resistant bacteria
            break;

        case "Fruit":                     //if the bulletTag is fruit
            bacteriaPenalty    = 0;       //0% penalty on bacteria
            virusPenalty       = 0;       //0% penalty on virus
            bacteriaResPenalty = 0;       //0% penalty on drug resistant bacteria
            break;

        default:
            bacteriaPenalty = 0;
            virusPenalty    = 0;
            bacteriaPenalty = 0;
            break;
        }
    }
Ejemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        lastSpawnTime = Time.time;
        gameManager   =
            GameObject.Find("GameManager").GetComponent <GameManagerBehavior>();
        gameManager.WaveCount = waves.Length;

        Difficulty difficulty = PersistantManager.GetDifficulty();

        switch (difficulty)
        {
        case Difficulty.EASY:
            foreach (Wave wave in waves)
            {
                wave.decreasePower();
            }
            break;

        case Difficulty.HARD:
            foreach (Wave wave in waves)
            {
                wave.increasePower();
            }
            break;
        }

        // Update target position according to current map
        GameObject target = GameObject.Find("Target");
        GameObject pos    = GameObject.Find("TargetPosition");

        target.transform.position = pos.transform.position;
    }
Ejemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        // 1
        Vector3 startPosition = waypoints[currentWaypoint].transform.position;
        Vector3 endPosition   = waypoints[currentWaypoint + 1].transform.position;
        // 2
        float pathLength        = Vector3.Distance(startPosition, endPosition);
        float totalTimeForPath  = pathLength / speed;
        float currentTimeOnPath = Time.time - lastWaypointSwitchTime;

        gameObject.transform.position = Vector2.Lerp(startPosition, endPosition, currentTimeOnPath / totalTimeForPath);
        // 3
        if (gameObject.transform.position.Equals(endPosition))
        {
            if (currentWaypoint < waypoints.Length - 2)
            {
                // 3.a
                currentWaypoint++;
                lastWaypointSwitchTime = Time.time;
                // TODO: Rotate into move direction
                RotateIntoMoveDirection();
            }
            else
            {
                // 3.b
                Destroy(gameObject);

                AudioSource audioSource = gameObject.GetComponent <AudioSource>();
                AudioSource.PlayClipAtPoint(audioSource.clip, transform.position);
                // TODO: deduct health
                GameManagerBehavior gameManager = GameObject.Find("GameManager").GetComponent <GameManagerBehavior>();
                gameManager.Health -= 1;
            }
        }
    }
Ejemplo n.º 4
0
    // Use this for initialization
    void Start()
    {
        startTime = Time.time;
        GameObject gm = GameObject.Find("GameManager");

        gameManager = gm.GetComponent <GameManagerBehavior>();
    }
	// Use this for initialization
	void Start () {
		lastSpawnTime = Time.time;
		gameManager =
			GameObject.Find("GameManager").GetComponent<GameManagerBehavior>();

		for (int i = 0; i < waves.Length; ++i) {

			if (waves [i].enemyPrefabs.Length < 1) {

				float difficultyFactor = 0;
				if (waveRandomizerDifficulty.linearScaling) {
					difficultyFactor = ((float)(i)) / waves.Length;
				} else {
					// should be quadratic scaling (I think)
					difficultyFactor = ((float)(i)) / waves.Length * ((float)(i)) / waves.Length;
				}
				float baseMinEnemyRange = (float)(waveRandomizerDifficulty.endMinEnemies - waveRandomizerDifficulty.baseMinEnemies);

				int minEnemies = (int) (baseMinEnemyRange * difficultyFactor + waveRandomizerDifficulty.baseMinEnemies);

				float baseMaxEnemyRange = (float)(waveRandomizerDifficulty.endMaxEnemies - waveRandomizerDifficulty.baseMaxEnemies);
				int maxEnemies = (int) (baseMaxEnemyRange * difficultyFactor + waveRandomizerDifficulty.baseMaxEnemies);

				float baseMinIntervalRange = waveRandomizerDifficulty.endMinInterval - waveRandomizerDifficulty.baseMinInterval;
				float minSpawnInterval = baseMinIntervalRange * difficultyFactor + waveRandomizerDifficulty.baseMinInterval;

				float baseMaxIntervalRange = waveRandomizerDifficulty.endMaxInterval - waveRandomizerDifficulty.baseMaxInterval;
				float maxSpawnInterval = baseMaxIntervalRange * difficultyFactor + waveRandomizerDifficulty.baseMaxInterval;

				GenerateRandomWave(waves[i], minEnemies, maxEnemies, minSpawnInterval, maxSpawnInterval);
			}
		}
		
	}
Ejemplo n.º 6
0
 // Use this for initialization
 void Start()
 {
     originalScale = gameObject.transform.localScale.x;
     gameManager   = GameObject.Find("GameManager").GetComponent <GameManagerBehavior>();
     maxHealth     = (float)(baseHealth * (1 + Mathf.Pow((gameManager.Wave - 1), 2)) * .7);
     currentHealth = maxHealth;
 }
    // Update is called once per frame
    void Update()
    {
        //From the waypoints array, you retrieve the start and end position for the current path segment.
        Vector3 startPosition = waypoints[currentWaypoint].transform.position;
        Vector3 endPosition   = waypoints[currentWaypoint + 1].transform.position;
        //Calculate the time needed for the whole distance with the formula time = distance / speed, then determine the current time on the path.
        //Using Vector3.Lerp, you interpolate the current position of the enemy between the segment’s start and end positions.
        float pathLength        = Vector3.Distance(startPosition, endPosition);
        float totalTimeForPath  = pathLength / speed;
        float currentTimeOnPath = Time.time - lastWaypointSwitchTime;

        gameObject.transform.position = Vector3.Lerp(startPosition, endPosition, currentTimeOnPath / totalTimeForPath);
        //Check whether the enemy has reached the endPosition.
        if (gameObject.transform.position.Equals(endPosition))
        {
            if (currentWaypoint < waypoints.Length - 2)
            {
                //The enemy is not yet at the last waypoint, so increase currentWaypoint and update lastWaypointSwitchTime.
                currentWaypoint++;
                lastWaypointSwitchTime = Time.time;
                RotateIntoMoveDirection(); //Roates enemy into correct direction
            }
            else
            {
                //The enemy reached the last waypoint, so this destroys it and triggers a sound effect.
                Destroy(gameObject);

                AudioSource audioSource = gameObject.GetComponent <AudioSource>();
                AudioSource.PlayClipAtPoint(audioSource.clip, transform.position);
                //This gets the GameManagerBehavior and subtracts one from its Health.
                GameManagerBehavior gameManager = GameObject.Find("GameManager").GetComponent <GameManagerBehavior>();
                gameManager.Health -= 1;
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        // 1  从路标数组中,取出当前路段的开始路标和结束路标
        Vector3 startPosition = waypoints[currentWaypoint].transform.position;
        Vector3 endPosition   = waypoints[currentWaypoint + 1].transform.position;

        // 2 计算出通过整个路段的距离
        float pathLength        = Vector2.Distance(startPosition, endPosition);
        float totalTimeForPath  = pathLength / speed; //计算出通过整个路段所需要的时间
        float currentTimeOnPath = Time.time - lastWaypointSwitchTime;

        // 计算出当前时刻应该在的位置
        gameObject.transform.position = Vector2.Lerp(startPosition, endPosition, currentTimeOnPath / totalTimeForPath);

        // 3 检查敌人是否已经抵达结束路标
        if (gameObject.transform.position.Equals(endPosition))
        {
            //敌人尚未抵达最终的路标
            if (currentWaypoint < waypoints.Length - 2)
            {
                currentWaypoint++;
                lastWaypointSwitchTime = Time.time;
            }
            else  //敌人抵达了最终的路标
            {
                Destroy(gameObject);

                AudioSource audioSource = gameObject.GetComponent <AudioSource>();
                AudioSource.PlayClipAtPoint(audioSource.clip, transform.position);

                GameManagerBehavior gameManager = GameObject.Find("GameManager").GetComponent <GameManagerBehavior>();
                gameManager.Health -= 1;
            }
        }
    }
Ejemplo n.º 9
0
    void Start()
    {
        Button btn = this.GetComponent <Button> ();

        btn.onClick.AddListener(OnClick);
        gameManager = GameObject.Find("GameManager").GetComponent <GameManagerBehavior>();
    }
Ejemplo n.º 10
0
 void Start()
 {
     //Instantiate(testEnemyPrefab).GetComponent<MoveEnemy>().waypoints = wayPoints;
     lastSpawnTime = Time.time;
     gameManager   =
         GameObject.Find("GameManager").GetComponent <GameManagerBehavior>();
 }
 void Start()
 {
     startTime = Time.time;
     distance = Vector3.Distance (startPosition, targetPosition);
     GameObject gm = GameObject.Find ("GameManager");
     gameManager = gm.GetComponent<GameManagerBehavior> ();
 }
Ejemplo n.º 12
0
 // Use this for initialization
 void Start()
 {
     enemiesInRange = new List <GameObject>();
     lastShotTime   = Time.time;
     monsterData    = gameObject.GetComponentInChildren <MonsterData>();
     gameManager    = GameObject.Find("GameManager").GetComponent <GameManagerBehavior>();
 }
Ejemplo n.º 13
0
    // Update is called once per frame
    void Update()
    {
        // Debug.Log("Size of Waypoints is : " + waypoints.Length);
        Vector3 startPosition = waypoints[currWaypoint].transform.position;
        Vector3 endPosition   = waypoints[currWaypoint + 1].transform.position;

        float pathLength        = Vector3.Distance(startPosition, endPosition);
        float totalTimeForPath  = pathLength / speed;
        float currentTimeOnPath = Time.time - lastWaypointSwitchTime;

        gameObject.transform.position = Vector2.Lerp(startPosition, endPosition, currentTimeOnPath / totalTimeForPath);
        RotateIntoMoveDirection();


        if (gameObject.transform.position.Equals(endPosition))
        {
            if (currWaypoint < waypoints.Length - 2)
            {
                currWaypoint++;
                lastWaypointSwitchTime = Time.time;
            }
            else
            {
                GameManagerBehavior gameManager = GameObject.Find("GameManager").GetComponent <GameManagerBehavior>();
                gameManager.Health -= 1;
                Destroy(gameObject);
                AudioSource audioSource = gameObject.GetComponent <AudioSource>();
                AudioSource.PlayClipAtPoint(audioSource.clip, transform.position);
            }
        }
    }
Ejemplo n.º 14
0
    // Update is called once per frame
    void Update()
    {
        // 1
        Vector3 startPosition = waypoints[currentWaypoint].transform.position;                                          //the current waypoint that they were last at
        Vector3 endPosition   = waypoints[currentWaypoint + 1].transform.position;                                      //the next waypoint they are going to
        // 2
        float pathLength        = Vector2.Distance(startPosition, endPosition);                                         //pathLength is the distance between the start and end
        float totalTimeForPath  = pathLength / speed;                                                                   //totalTimeForPath is pathLength divided by speed
        float currentTimeOnPath = Time.time - lastWaypointSwitchTime;                                                   //currentTimeOnPath is current time minus lastWaypointSwitchTime

        gameObject.transform.position = Vector2.Lerp(startPosition, endPosition, currentTimeOnPath / totalTimeForPath); //updates enemy position by linearly interpolating from start positon to end position by the currentTime divided by totalTime
        // 3
        if (gameObject.transform.position.Equals(endPosition))                                                          //if the enemy reaches the end position
        {
            if (currentWaypoint < waypoints.Length - 2)                                                                 //if the currentWaypoint is not in the last 2 waypoints (because last 2 waypoints is a straight line)
            {
                currentWaypoint++;                                                                                      //currentwaypoint increases by 1
                lastWaypointSwitchTime = Time.time;                                                                     //update lastWayPointSwitchTime to current time

                //RotateIntoMoveDirection();                                    //call RotateIntoMoveDireciton
            }
            else
            {
                Destroy(gameObject);                                         //if it reaches the last waypoint, it will destroy the gameobject

                AudioSource audioSource = gameObject.GetComponent <AudioSource>();
                AudioSource.PlayClipAtPoint(audioSource.clip, transform.position);

                GameManagerBehavior gameManager =
                    GameObject.Find("GameManager").GetComponent <GameManagerBehavior>();
                gameManager.Health -= 1;                                    //player loses a health
            }
        }
    }
Ejemplo n.º 15
0
    // Use this for initialization
    void Start () {
        lastSpawnTime = Time.time;
        gameManager =
            GameObject.Find("GameManager").GetComponent<GameManagerBehavior>();


    }
Ejemplo n.º 16
0
    // Use this for initialization
    void Start()
    {
        lastSpawnTime = Time.time;
        gameManager   = GameObject.Find("GameManager").GetComponent <GameManagerBehavior>();

        flowchart    = gameManager.flowchart;
        flowchartObj = gameManager.flowchartObj;
    }
Ejemplo n.º 17
0
 // Start is called before the first frame update
 void Start()
 {
     //получаем стартовое количество золота
     gameManager = GameObject.Find("GameManager").GetComponent <GameManagerBehavior>();
     //на старте располагаем башни на заданных точках
     monster = (GameObject)
               Instantiate(monsterPrefab, transform.position, Quaternion.identity);
 }
Ejemplo n.º 18
0
 // Use this for initialization
 void Start()
 {
     lastSpawnTime = Time.time;
     gameManager   =
         GameObject.Find("GameManager").GetComponent <GameManagerBehavior>();
     gameManager.maxWaves = waves.Length;
     gameManager.Wave     = gameManager.Wave;
 }
Ejemplo n.º 19
0
    private void Start()
    {
        startTime = Time.time;
        distance  = Vector3.Distance(startPosition, targetPosition);
        GameObject gm = GameObject.Find("GameManager");

        gameManager = gm.GetComponent <GameManagerBehavior>();
    }
Ejemplo n.º 20
0
    // Use this for initialization
    void Start()
    {
        //vain testaukseen, wanha
        //Instantiate(testEnemyPrefab).GetComponent<MoveEnemy>().waypoints = waypoints;

        lastSpawnTime = Time.time;
        gameManager =
            GameObject.Find("GameManager").GetComponent<GameManagerBehavior>();
    }
	//private bool isReady = false;

	// Use this for initialization
	void Start () {
		b1Btn = transform.FindChild("Build1");
		b2Btn = transform.FindChild("Build2");
		b3Btn = transform.FindChild("Build3");
		canBtn = transform.FindChild("Cancel");
		ring = transform.FindChild("Ring");

		gameManager = GameObject.Find("GameManager").GetComponent<GameManagerBehavior>();

		hideMenu ();
	}
Ejemplo n.º 22
0
    // private Transform circelRanger;


    // public UIEventListener[] allWarEvent;

    // Use this for initialization
    void Start()
    {
        gameManager = GameObject.Find("GameManager").GetComponent <GameManagerBehavior>();
        upAndSlod   = Resources.Load <GameObject>("UpAndSold") as GameObject;
        //mySelfGameObject = transform.gameObject;
        //moddleSprite = GameObject.FindWithTag("middle");
        //foreach (UIEventListener e in allWarEvent)
        //{
        //    e.onClick += _btnClicked;
        //}
        UIEventListener.Get(this.transform.gameObject).onClick = _btnClicked;
    }
	// Use this for initialization
	void Start () {
		startTime = Time.time;
		distance = Vector3.Distance (startPosition, targetPosition);
		GameObject gm = GameObject.Find("GameManager");
		gameManager = gm.GetComponent<GameManagerBehavior>();	

		enemiesInRange = new List<GameObject>();

		if (aoeRange > 0) {
			GetComponent<CircleCollider2D> ().radius = aoeRange;
		}
	}
Ejemplo n.º 24
0
    // Update is called once per frame
    void Update()
    {
        // 1
        Vector3 startPosition = waypoints [currentWaypoint].transform.position;
        Vector3 endPosition   = waypoints [currentWaypoint + 1].transform.position;
        // 2
        float tempSpeed = speed;

        if (isBeingSlow)
        {
            totalSlowTime += Time.deltaTime;
            if (totalSlowTime >= maxSlowTime)
            {
                isBeingSlow = false;
                animator.SetBool("isSlow", false);
            }
            tempSpeed = tempSpeed * 60 / 100;
        }
        float pathLength        = Vector3.Distance(startPosition, endPosition);
        float totalTimeForPath  = pathLength / tempSpeed;
        float currentTimeOnPath = Time.time - lastWaypointSwitchTime;

        gameObject.transform.position = Vector3.Lerp(startPosition, endPosition, currentTimeOnPath / totalTimeForPath);
        // 3
        if (gameObject.transform.position.Equals(endPosition))
        {
            if (currentWaypoint < waypoints.Length - 2)
            {
                // 4 Switch to next waypoint
                currentWaypoint++;
                lastWaypointSwitchTime = Time.time;

                RotateIntoMoveDirection();
            }
            else
            {
                // 5 Destroy enemy
                Destroy(gameObject);

                AudioSource audioSource = gameObject.GetComponent <AudioSource>();
                AudioSource.PlayClipAtPoint(audioSource.clip, transform.position);

                GameManagerBehavior gameManager =
                    GameObject.Find("GameManager").GetComponent <GameManagerBehavior>();
                gameManager.Health -= 1;
                if (isVibrationEnabled)
                {
                    Handheld.Vibrate();
                }
            }
        }
    }
Ejemplo n.º 25
0
 public static void RemoveNode(GameObject node, GameManagerBehavior GameManager)
 {
     if (node != null)
     {
         NodeBehavior nodeBehavior = node.GetComponent <NodeBehavior>();
         if (nodeBehavior.parent != null)
         {
             NodeBehavior pb = nodeBehavior.parent.GetComponent <NodeBehavior>();
             pb.myKids.Remove(node.transform);
         }
         GameObject.Destroy(node);
     }
 }
	//private Transform resumeBtn;
	//private Transform mainBtn;
	//private Transform quitBtn;



	// Use this for initialization
	void Start () {
		gameManager = GameObject.Find("GameManager").GetComponent<GameManagerBehavior>();
		gameManager.establishPauseMenu (gameObject);

		musicBtn = transform.parent.transform.FindChild("Music");
		soundBtn = transform.parent.transform.FindChild("Sound");
		//resumeBtn = transform.parent.transform.FindChild("Resume");
		//mainBtn = transform.parent.transform.FindChild("Main");
		//quitBtn = transform.parent.transform.FindChild("Quit");


		transform.parent.transform.localScale = new Vector3 (0, 0, 0);
	}
Ejemplo n.º 27
0
 // Use this for initialization
 void Start()
 {
     if (this.currentSpace == null)
     {
         this.currentSpace = startingSpace;
         SetInitialPositionAndDestination();
     }
     if (this.Inventory == null)
     {
         this.Inventory = new Inventory();
     }
     this.gameManager = GameObject.FindWithTag(Tags.GameManager).GetComponent <GameManagerBehavior>();
     this.UpdateHUD();
 }
	void Awake() {

		gameManager = GameObject.Find("GameManager").GetComponent<GameManagerBehavior>();

		upBtn = transform.parent.transform.FindChild("Upgrade");
		canBtn = transform.parent.transform.FindChild("Cancel");
		ring = transform.parent.transform.FindChild("Ring");
		hideMenu ();



		//transform.parent.GetComponent<Button>().onClick.AddListener(() => { OnMouseUp(); OnMouseUp(); }); 

	}
Ejemplo n.º 29
0
    // Use this for initialization
    void Start()
    {
        gameManager       = GameObject.Find("GameManager").GetComponent <GameManagerBehavior>();
        topUpgradeMenu    = GameObject.Find("UpgradePanelTop");
        bottomUpgradeMenu = GameObject.Find("UpgradePanelBottom");
        hudCanvas         = GameObject.Find("HUD Canvas").GetComponent <Canvas>();

        // Add offset to make range preview always behind selector
        rangePreview = (GameObject)Instantiate(
            rangePrefab, transform.position + new Vector3(0, 0, 1), Quaternion.identity);
        rangePreview.SetActive(false);

        isAmbientEnabled = PersistantManager.IsAmbientEnabled();
    }
Ejemplo n.º 30
0
 void Awake()
 {
     if (instance == null)
     {
         this.numberOfTurnsRemaining = 23;   //23 days until Xmas
         instance = this;
         DontDestroyOnLoad(gameObject);
         SceneManager.sceneLoaded += OnSceneLoaded;
     }
     else if (instance != this)
     {
         Destroy(this.gameObject);
         return;
     }
 }
Ejemplo n.º 31
0
    void Start()
    {
        _gameManagerBehavior = GameObject.Find("$GameManager").GetComponent <GameManagerBehavior>();

        if (Effect != EffectType.None)
        {
            PlayEffectSound();
        }
        if (VibrateDuration != 0 && PlayerPrefs.GetInt("Vibrations", 1) == 1)
        {
            Vibration.Vibrate(VibrateDuration);
        }
        Invoke("HideAfterDelay", DelayBeforeHide);
        Invoke("DestroyAfterDelay", DelayBeforeDestroy);
    }
Ejemplo n.º 32
0
 // Use this for initialization
 protected virtual void Awake()
 {
     _health     = _max_health;
     gameManager = GameObject.Find("GameManager").GetComponent <GameManagerBehavior>();
     rb          = GetComponent <Rigidbody>();
     GetHealthBar();
     _anim        = gameObject.GetComponent <Animator>();
     _collider    = GetComponent <Collider>();
     _highlighter = GetComponentInChildren <Light>();
     if (_highlighter)
     {
         _highlighter.enabled = false;
     }
     _sprite = GetComponent <SpriteRenderer>();
 }
Ejemplo n.º 33
0
    void Start()
    {
        gameManager = GameObject.Find("GameManager").GetComponent <GameManagerBehavior> ();

        lastEnemyCounter   = 0;
        lastEnemySpawnTime = 0;

        waveCounter = 0;

        waveActive = false;

        enemiesToSpawn = 0;
        gameManager.SetRemainingEnemies(enemySpawnCounter);

        WaveInfo.ReadFromJSONFile(1);
    }
Ejemplo n.º 34
0
    // Update is called once per frame
    void Update()
    {
        // 1
        Vector3 startPosition = waypoints [currentWaypoint].transform.position;
        Vector3 endPosition   = waypoints [currentWaypoint + 1].transform.position;
        // 2
        float pathLength        = Vector3.Distance(startPosition, endPosition);
        float totalTimeForPath  = pathLength / speed;
        float currentTimeOnPath = Time.time - lastWaypointSwitchTime;

        gameObject.transform.position = Vector2.Lerp(startPosition, endPosition, currentTimeOnPath / totalTimeForPath);
        // 3
        // Kejin modify:
        if (Healthtrans.localScale.x <= 0)
        {
            Destroy(gameObject);
        }
        //kejin end
        if (Vector3.Distance(gameObject.transform.position, endPosition) < 0.1f)
        //if (gameObject.transform.position.Equals(endPosition))
        {
            if (currentWaypoint < waypoints.Length - 2)
            {
                // 3.a
                currentWaypoint++;
                lastWaypointSwitchTime = Time.time;
                // TODO: Rotate into move direction
                RotateIntoMoveDirection();
            }
            else
            {
                // 3.b
                Destroy(gameObject);
                GameManagerBehavior gameManager = GameObject.Find("GameManager").GetComponent <GameManagerBehavior>();
                gameManager.Gold += goldEarn;
                gameManager.AllyNum++;
                if (AllyType == 2)
                {
                    Type2();
                }
                if (AllyType == 3)
                {
                    gameManager.Health++;
                }
            }
        }
    }
Ejemplo n.º 35
0
    // Update is called once per frame
    void Update()
    {
        float time = Time.time;
        int   t    = (int)time;
        float ta   = t + 0.05f;

        if (time < ta && currentSpeed < speed)
        {
            CurrentSpeed = speed;
        }
        // 1
        Vector3 endPosition = waypoints [currentWaypoint + 1].transform.position;
        // 2
        float pathLength        = Vector3.Distance(startPosition, endPosition);
        float totalTimeForPath  = pathLength / currentSpeed;
        float currentTimeOnPath = Time.time - lastWaypointSwitchTime;

        gameObject.transform.position = Vector3.Lerp(startPosition, endPosition, currentTimeOnPath / totalTimeForPath);
        // 3
        if (gameObject.transform.position.Equals(endPosition))
        {
            if (currentWaypoint < waypoints.Length - 2)
            {
                // 4 Switch to next waypoint
                currentWaypoint++;
                lastWaypointSwitchTime = Time.time;
                startPosition          = waypoints [currentWaypoint].transform.position;
                RotateIntoMoveDirection();
            }
            else
            {
                // 5 Destroy enemy
                Destroy(gameObject);

                if (AppData.isSoundOn)
                {
                    AudioSource audioSource = gameObject.GetComponent <AudioSource>();
                    AudioSource.PlayClipAtPoint(audioSource.clip, transform.position);
                }
                GameManagerBehavior gameManager =
                    GameObject.Find("GameManager").GetComponent <GameManagerBehavior>();
                gameManager.Health -= 1;
                gameManager.Fall();
            }
        }
    }
    void Awake()
    {
        //Sets a refference to the GameManager
        _gameManager = GetComponent <GameManagerBehavior>();

        if (gameObject.CompareTag("Across"))
        {
            //Add 0.1f to the speed
            speed = 0.25f;
        }

        if (gameObject.CompareTag("Down"))
        {
            //Add 0.1f to the speed
            speed = 1;
        }
    }
Ejemplo n.º 37
0
        public static int levelDifficulty;                                                     //level currently playing

        // Start is called before the first frame update
        void Start()
        {
            gMB = GameObject.Find("GameManager").GetComponent <GameManagerBehavior>();

            totalLevels = new Button[transform.childCount];                                    //get total number of levels based on number of buttons

            if (StartUI.activeSelf == true)
            {
                LevelSelectMenu.SetActive(false);
            }

            if (Player.tdunlockedlevels < 1)                                                    //set starting level to 1
            {
                Player.tdunlockedlevels = 1;
            }

            playableLevels = Player.tdunlockedlevels;
        }
Ejemplo n.º 38
0
    // Use this for initialization
    void Start()
    {
        startTime = Time.time;
        GameObject gm = GameObject.Find("GameManager");

        gameManager = gm.GetComponent <GameManagerBehavior>();

        if (target.Count > 0)
        {
            Vector3 direction = gameObject.transform.position - target[0].transform.position;
            gameObject.transform.rotation = Quaternion.AngleAxis(
                Mathf.Atan2(direction.y, direction.x) * 180 / Mathf.PI,
                new Vector3(0, 0, 1));
            transform.rotation = Quaternion.AngleAxis(
                Mathf.Atan2(direction.y, direction.x) * 180 / Mathf.PI,
                new Vector3(0, 0, 1));
        }
    }
 void Start()
 {
     lastWaypointSwitchTime = Time.time;
     gameManager = GameObject.Find ("GameManager").GetComponent<GameManagerBehavior> ();
 }
Ejemplo n.º 40
0
	// Use this for initialization
	void Start () {
	gameManager = GameObject.Find("GameManager").GetComponent<GameManagerBehavior>();
	}