// Update is called once per frame void Update() { if(hit_points < 0){ if(myOwner == TOWEROWNER.RODELLE){ myOwner = TOWEROWNER.PEASANT; this.renderer.material.color = Color.red; hit_points = MAX_HIT_POINTS; } else{ myOwner = TOWEROWNER.RODELLE; this.renderer.material.color = Color.green; hit_points = MAX_HIT_POINTS; } } if(Input.GetMouseButtonUp(1)){ if(selected){ spawnLocation = Camera.main.ScreenToWorldPoint(Input.mousePosition); selected = false; } } if(Input.GetKey(KeyCode.A)){ if(Time.realtimeSinceStartup - aButtonTime > BUTTON_INTER){ if(myTowerType == TOWERTYPE.MELEETOWER){ hit_points--; aButtonTime = Time.realtimeSinceStartup; } } } if(Input.GetKey(KeyCode.S)){ if(Time.realtimeSinceStartup - sButtonTime > BUTTON_INTER){ if(myTowerType == TOWERTYPE.RANGEDTOWER){ hit_points--; sButtonTime = Time.realtimeSinceStartup; } } } if(Input.GetKey(KeyCode.D)){ if(Time.realtimeSinceStartup - dButtonTime > BUTTON_INTER){ if(myTowerType == TOWERTYPE.MAGICTOWER){ hit_points--; dButtonTime = Time.realtimeSinceStartup; } } } if(Input.GetKey(KeyCode.F)){ if(Time.realtimeSinceStartup - fButtonTime > BUTTON_INTER){ if(myTowerType == TOWERTYPE.HEALTOWER){ hit_points--; fButtonTime = Time.realtimeSinceStartup; } } } }
// Use this for initialization void Start() { spawnLocation = transform.position; spawnLocation += new Vector2(Mathf.Sign(transform.position.x) * -1 * transform.localScale.x, Mathf.Sign(transform.position.y) * -1 * transform.localScale.y); if(gameManager == null) GameObject.Find("GameManager").GetComponent<GameManager>(); hit_points = MAX_HIT_POINTS; myOwner = TOWEROWNER.RODELLE; // this.renderer.material.color = Color.green; }