// Use this for initialization void Start() { primaryWeapon = Instantiate(primaryWeapon); primaryWeapon.GetComponent <SpriteRenderer>().enabled = false; backupCQC = Instantiate(backupCQC); backupCQC.GetComponent <SpriteRenderer>().enabled = false; // need to find a new home for these, maybe in the game manager somewhere. previousDirectionOfTravel = new Vector2(0, 1); currentRollState = rollStates.CANROLL; status = lifeState.OK; }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.GetComponent <Projectile>() != null) { if (collision.gameObject.GetComponent <Projectile>().getBulletColor() != teamOn) { this.gameObject.SetActive(false); status = lifeState.ELIMINATED; } } }
public void changeLifeState(lifeState inboundLifeState) { status = inboundLifeState; }
void takeDeath(GameObject attacker) { if(attacker.GetComponentInParent<Character>()){ attacker.GetComponentInParent<Character> ().addKill (); } if(attacker.GetComponent<boulderScript>()){ Golem[] magPar = FindObjectsOfType<Golem>(); foreach(Golem m in magPar){ if(m.playerNumber == attacker.GetComponent<boulderScript>().parentNumber){ m.GetComponent<Character>().addKill(); } } } if (attacker.tag == "Death") { if(lastHit){ lastHit.addKill(); } } lifeState_ = lifeState.STATE_DEAD; deaths ++; lives--; }
void respawn() { int randmTaunt = Random.Range(0,taunts.Length); this.GetComponent<AudioSource> ().PlayOneShot (taunts [randmTaunt], 1.0f); GameObject[] spawnLocs = GameObject.FindGameObjectsWithTag("Respawn"); int pickSpawn = Random.Range (0, spawnLocs.Length); if (spawnLocs.Length > 0) { spawnLocs [pickSpawn].GetComponentInChildren<ParticleSystem> ().Play (); this.gameObject.transform.position = spawnLocs [pickSpawn].transform.position; } lifeState_ = lifeState.STATE_ALIVE; health = maxHealth; isHurt = false; }
/************* Start ******************/ public void Start() { outageFont = Resources.Load ("Outage") as Font; hudInfo = new GameObject(); hudInfo.AddComponent<Text> (); hudInfo.GetComponent<Text> ().font = outageFont; hudInfo.transform.SetParent (FindObjectOfType<Canvas> ().transform); body = this.GetComponent<CharacterController> (); model = this.GetComponentInChildren<Animator>(); skin = this.GetComponentsInChildren<Renderer>(); charAttacks = this.GetComponentInChildren<attacks> (); health = maxHealth; canMove = true; lifeState_ = lifeState.STATE_ALIVE; maxGravity = -20.0f; gravity = maxGravity; canDash = true; canListen = true; }