예제 #1
0
 private void Start()
 {
     minionSpeed = enemyModel.movementSpeed;
     casteHealth = GameObject.FindGameObjectWithTag("Castle").GetComponent <CastleHealth>();
     UILog       = GameObject.FindGameObjectWithTag("Canvas").GetComponentInChildren <Text>(true);
     EventManager.TriggerEvent(enemyName + "born");
 }
예제 #2
0
 //activated the barrel trap collider
 public static void Activated(GameObject currentObject)
 {
     b_Collider         = currentObject.GetComponent <Collider> ();
     b_Collider.enabled = true;
     CastleHealth.DealDamage(5f);
     activated = true;
 }
예제 #3
0
    // Update is called once per frame
    void Update()
    {
        HealthShow = Health;
        Tijd      += 1 * Time.deltaTime;
        if (transform.position.x < 12)
        {
            //update position to a new vector3(x,y,z). the x variable determines the speed of the object
            transform.position = transform.position + new Vector3(speed * Time.deltaTime, 0, 0);
        }
        if (transform.position.x >= 12)
        {
            GameObject   w            = GameObject.Find("Castle");
            CastleHealth castleHealth = w.GetComponent <CastleHealth>();
            castleHealth.currentwallHP  -= 0.5f * Time.deltaTime;
            castleHealth.healthText.text = "Health: " + castleHealth.currentwallHP.ToString("0") + "%";
            if (castleHealth.currentwallHP <= 0)
            {
                castleHealth.healthText.text = "Game over.";
                GameObject  s           = GameObject.Find("Spawner");
                SpawnScript spawnScript = s.GetComponent <SpawnScript>();
                spawnScript.stopSpawning = true;
            }
        }

        if (Health <= 0)
        {
            //destroy gameobject attached to this script
            Destroy(this.gameObject);
        }
    }
예제 #4
0
 private void Awake()
 {
     if (instance != null)
     {
         return;
     }
     instance = this;
 }
예제 #5
0
    public void LoadUIData()
    {
        GameObject   gameUI          = GameObject.FindGameObjectWithTag("Castle");
        CastleHealth tempCasteHealth = gameUI.GetComponent <CastleHealth>();

        tempCasteHealth.timeRemaining = Game.current.UI_Data.timer;
        tempCasteHealth.currentHealth = Game.current.UI_Data.currentHealth;
    }
예제 #6
0
 void doDamage()
 {
     if (dead != true && isEnded == true)
     {
         Levels.Play();
         CastleHealth.DealDamage(damage);
     }
 }
예제 #7
0
    public void saveUIData()
    {
        GameObject   gameUI          = GameObject.FindGameObjectWithTag("Castle");
        CastleHealth tempCasteHealth = gameUI.GetComponent <CastleHealth>();

        UI_Data.currentHealth = tempCasteHealth.currentHealth;
        UI_Data.timer         = tempCasteHealth.timeRemaining;
        //UI_Data.score = tempCasteHealth.s
    }
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
예제 #9
0
    private IEnumerator timer()
    {
        CastleHealth.GainHealth(hp);
        foreach (GameObject particle in particleChildren)
        {
            Destroy(particle);
        }
        Shoot.Play();
        yield return(new WaitForSeconds(2));

        Destroy(Parent);
    }
예제 #10
0
    //private Target target;



    void OnTriggerEnter(Collider other)
    {
        damageSound.Play();

        Debug.Log("Damage!");
        castle = FindObjectOfType <CastleHealth>();
        castle.CastleDam();
        //target = FindObjectOfType<Target>();
        Instantiate(explosion, transform.position, transform.rotation);
        Destroy(other.gameObject);
        Destroy(gameObject);
        //target.damage += 1;
    }
예제 #11
0
    public void Init(GameObject tower)
    {
        // ShowTowerPopup window = ScriptableObject.CreateInstance<ShowTowerPopup>();
        // window.position = new Rect(Screen.width / 2 + 100, Screen.height / 2 - 50, 300, 300);
        // GetComponent<Canvas> ().enabled = true;

        castle = GameObject.Find("Castle").GetComponent <CastleHealth>();
        uGen   = Camera.main.GetComponent <UnitGenerator>();
        cFire  = tower.transform.FindChild("Turret").GetComponent <CannonFire>();

        // pause game
        previousTimeScale = Time.timeScale;
        Time.timeScale    = 0;
    }
예제 #12
0
    void Start()
    {
        health        = GetComponent <Health>();
        rangeCollider = GetComponentInChildren <RangeCollider>();
        TryGetComponent <Shooter>(out myShooter);

        audioManager = AudioManager.instance;
        anim         = GetComponent <Animator>();
        castleHealth = CastleHealth.instance;
        sr           = transform.GetComponentInChildren <SpriteRenderer>();

        startingBluntDamage    = bluntDamage;
        startingSlashDamage    = slashDamage;
        startingPiercingDamage = piercingDamage;
        startingFireDamage     = fireDamage;

        StartCoroutine(Movement());
    }
예제 #13
0
 // Use this for initialization
 void Start()
 {
     castle = GameObject.Find("Castle").GetComponent <CastleHealth>();
     //GetComponent<Canvas> ().enabled = false;
     GameObject.Find("TrainingWindow").GetComponent <Canvas>().enabled = false;
     GameObject.Find("TrainButton").GetComponent <Button> ()
     .onClick.AddListener(delegate {
         if (castle.canPurchase(price))
         {
             train();
             GetComponent <Canvas> ().enabled = false;
         }
         else if (!castle.canPurchase(price))
         {
             Debug.Log("Not enough money");
         }
         else if (getTotalUnits() == 0)
         {
             Debug.Log("No units to train!");
         }
     });
 }
 void Start()
 {
     castleHealth = CastleHealth.instance;
 }
예제 #15
0
 // Update the current health value at health bar
 void Update()
 {
     record.text           = "Castle Health: " + CastleHealth.currentHealthLevel + "/200";
     CastleHealthBar.value = CastleHealth.CalculateHealth();
 }
예제 #16
0
 // Use this for initialization
 void Start()
 {
     money            = GameObject.Find("Castle").GetComponent <CastleHealth>();
     amountMoney.text = "$" + money.curMoney;
 }
예제 #17
0
 // Use this for initialization
 void Start()
 {
     buildingPlacement = GetComponent <BuildingPlacement>();
     buildingPlacement.SetManager(this);
     castle = GameObject.Find("Castle").GetComponent <CastleHealth>();
 }
예제 #18
0
 // Use this for initialization
 void Start()
 {
     castle = GameObject.Find("Castle").GetComponent<CastleHealth>();
     //GetComponent<Canvas> ().enabled = false;
     GameObject.Find("TrainingWindow").GetComponent<Canvas>().enabled = false;
     GameObject.Find ("TrainButton").GetComponent<Button> ()
         .onClick.AddListener (delegate {
             if(castle.canPurchase(price)) {
                 train();
                 GetComponent<Canvas> ().enabled = false;
             } else if(!castle.canPurchase(price)) {
                 Debug.Log("Not enough money");
             } else if(getTotalUnits() == 0) {
                 Debug.Log("No units to train!");
             }
         });
 }
예제 #19
0
    public void Init(GameObject tower)
    {
        // ShowTowerPopup window = ScriptableObject.CreateInstance<ShowTowerPopup>();
        // window.position = new Rect(Screen.width / 2 + 100, Screen.height / 2 - 50, 300, 300);
        // GetComponent<Canvas> ().enabled = true;

        castle = GameObject.Find("Castle").GetComponent<CastleHealth>();
        uGen = Camera.main.GetComponent<UnitGenerator>();
        cFire = tower.transform.FindChild("Turret").GetComponent<CannonFire>();

        // pause game
        previousTimeScale = Time.timeScale;
        Time.timeScale = 0;
    }
 // Use this for initialization
 void Start()
 {
     buildingPlacement = GetComponent<BuildingPlacement>();
     buildingPlacement.SetManager (this);
     castle = GameObject.Find("Castle").GetComponent<CastleHealth>();
 }
 // Update is called once per frame
 void Update()
 {
     money = GameObject.Find("Castle").GetComponent<CastleHealth>();
     amountMoney.text = "$" + money.curMoney;
 }
예제 #22
0
 // Use this for initialization
 void Start()
 {
     health            = GameObject.Find("Castle").GetComponent <CastleHealth>();
     amountHealth.text = (int)(health.curHealth * 100) + "/100";
 }
예제 #23
0
 void Start()
 {
     castleHealth = GetComponent <CastleHealth>();
 }
예제 #24
0
 // Update is called once per frame
 void Update()
 {
     health            = GameObject.Find("Castle").GetComponent <CastleHealth>();
     amountHealth.text = (int)Mathf.Round((health.curHealth * 100)) + "/100";
 }