public void StartUp() { character = GetComponent <SCR_character>(); //player=GameObject.FindWithTag ("Player").GetComponent<SCR_character>(); setMYPlayer(); CheckPlayerDistance(0); aggression = Mathf.Clamp(aggression, 1, 5); float aggressionMult = ((aggression - 1) * 0.7f); attackFreq[0] = (2.8f - aggressionMult); attackFreq[1] = (attackFreq[0] + 0.55f); if (alerted) { if (currentTargetEnemy != null) { character.SetRotAngle(currentTargetEnemy.transform.position); } } else { character.SetPatrolSpeed(true); character.SetRandomRotAngle(); SetPatrolAction(0); actionCounter = (actionLimit * 0.7f); } character.SetRotTarget(); transform.rotation = character.rotTarget; }
void TargetLock() { target = null; GameObject[] targets = GameObject.FindGameObjectsWithTag(targetStr); float shortestDistance = Mathf.Infinity; if (targets.Length > 0) { foreach (GameObject t in targets) { SCR_character c = t.GetComponent <SCR_character>(); if (c.stunned < 2 && c.invulnerable == false) { float dist = Vector2.Distance(new Vector2(transform.position.x, transform.position.z), new Vector2(t.transform.position.x, t.transform.position.z)); if (dist <= (attackRange + (t.GetComponent <BoxCollider>().size.x *t.transform.localScale.x)) && dist < shortestDistance) { target = t.transform; shortestDistance = dist; } } } } if (target) { lockActive = true; } }
public void StartUp() { character=GetComponent<SCR_character>(); characterHealth=GetComponent<SCR_characterHealth>(); GetComponent<SCR_characterHealth>().StartUp(1000); if(GameObject.Find("MAIN").GetComponent<SCR_main>().reticleOn){ GameObject reticleInst=Instantiate(Resources.Load ("Objects/Gui/OBJ_reticle",typeof(GameObject)),Vector3.zero,Quaternion.identity) as GameObject; reticle=reticleInst.GetComponent<SCR_reticle>(); } }
public void StartUp() { character = GetComponent <SCR_character>(); characterHealth = GetComponent <SCR_characterHealth>(); GetComponent <SCR_characterHealth>().StartUp(1000); if (GameObject.Find("MAIN").GetComponent <SCR_main>().reticleOn) { GameObject reticleInst = Instantiate(Resources.Load("Objects/Gui/OBJ_reticle", typeof(GameObject)), Vector3.zero, Quaternion.identity) as GameObject; reticle = reticleInst.GetComponent <SCR_reticle>(); } }
void Awake() { character = GetComponent <SCR_character>(); attackReady = true; attackBufferAllowed = true; dir = new GameObject("rangedDir"); Transform dirTrans = dir.transform; dirTrans.parent = transform; dir.transform.localPosition = Vector3.zero; SND_shot = SCR_main.SetupSoundArray(transform, shotSound, true, true); }
public void AttackHit() { if (lockActive == false) { TargetLock(); } if (lockActive) { float dist = Vector2.Distance(new Vector2(transform.position.x, transform.position.z), new Vector2(target.transform.position.x, target.transform.position.z)); if (dist <= (attackRange + (target.GetComponent <BoxCollider>().size.x *target.transform.localScale.x))) { bool hitSuccess = target.GetComponent <SCR_characterHealth>().Damage(damage); if (hitSuccess) { SCR_character targetCha = target.GetComponent <SCR_character>(); Vector3 hitDir = (new Vector3(target.transform.position.x, 0f, target.transform.position.z) - new Vector3(transform.position.x, 0f, transform.position.z)); float distTotal = hitDir.magnitude; hitDir /= distTotal; targetCha.speed[0] += (hitDir * force); if (attackHitObj) { Vector3 relativePos = (target.transform.position - transform.position); Quaternion attackRotation = Quaternion.LookRotation(relativePos); GameObject attackHitInst = Instantiate(attackHitObj, transform.position, attackRotation) as GameObject; Vector3 attackHitPos = (transform.position + (attackHitInst.transform.forward * attackHitOffset.z) + (attackHitInst.transform.up * attackHitOffset.y) + (attackHitInst.transform.right * attackHitOffset.x)); attackHitInst.transform.position = attackHitPos; } SCR_main.PlayRandomSound(SND_attackHit); } } } }
public void StartUp(int id) { health=healthMax; character=GetComponent<SCR_character>(); bool deathSoundRandomPitch=true; if(character.isPlayer){ deathSoundRandomPitch=false; } //death sound SND_death=SCR_main.SetupSoundArray(transform,deathSound,deathSoundRandomPitch,true); GameObject healthBarInst=Instantiate(SCR_main.healthBarObj,Vector3.zero,Quaternion.identity) as GameObject; healthBar=healthBarInst.GetComponent<SCR_healthBar>(); healthBar.StartUp(id); UpdateHealthBar(); }
public void StartUp(bool isPlayer) { character = GetComponent <SCR_character>(); attackReady = true; attackBufferAllowed = true; attackRange *= transform.localScale.x; if (isPlayer) { targetStr = "Enemy"; } else { targetStr = "Player"; } SND_attack = SCR_main.SetupSoundArray(transform, attackSound, true, true); SND_attackHit = SCR_main.SetupSoundArray(transform, attackHitSound, true, true); }
public void StartUp(int id) { health = healthMax; character = GetComponent <SCR_character>(); bool deathSoundRandomPitch = true; if (character.isPlayer) { deathSoundRandomPitch = false; } //death sound SND_death = SCR_main.SetupSoundArray(transform, deathSound, deathSoundRandomPitch, true); GameObject healthBarInst = Instantiate(SCR_main.healthBarObj, Vector3.zero, Quaternion.identity) as GameObject; healthBar = healthBarInst.GetComponent <SCR_healthBar>(); healthBar.StartUp(id); UpdateHealthBar(); }
public void StartUp(bool isPlayer) { character=GetComponent<SCR_character>(); attackReady=true; attackBufferAllowed=true; attackRange*=transform.localScale.x; if(isPlayer){ targetStr="Enemy"; } else { targetStr="Player"; } SND_attack=SCR_main.SetupSoundArray(transform,attackSound,true,true); SND_attackHit=SCR_main.SetupSoundArray(transform,attackHitSound,true,true); }
void Awake() { GameObject m = GameObject.Find("MAIN"); main = m.GetComponent <SCR_main>(); music = m.GetComponent <SCR_music>(); if (stageMusic && SCR_main.hMusic) { music.PlayMusic(stageMusic); } SCR_input.playerControlActive = false; pauseAllowed = false; paused = false; SCR_main.scoreRec = SCR_main.score; scoreRec = SCR_main.score; GameObject camInst = Instantiate(stageCamera, Vector3.zero, Quaternion.identity) as GameObject; GameObject spawnPointPlayer = GameObject.Find("SpawnPointPlayer"); Vector3 playerPos = new Vector3(spawnPointPlayer.transform.position.x, 0f, spawnPointPlayer.transform.position.z); if (main.playerSelect == true) { GameObject playerInst = Instantiate(main.playerObj1, playerPos, Quaternion.identity) as GameObject; Destroy(spawnPointPlayer); player = playerInst.GetComponent <SCR_character>(); SetupStageSize(); cam = camInst.GetComponent <SCR_camStage>(); cam.SetTarget(playerInst.transform); cam.InitiateStage(0); } else if (main.playerSelect == false) { GameObject playerInst = Instantiate(main.playerObj2, playerPos, Quaternion.identity) as GameObject; Destroy(spawnPointPlayer); player = playerInst.GetComponent <SCR_character>(); SetupStageSize(); cam = camInst.GetComponent <SCR_camStage>(); cam.SetTarget(playerInst.transform); cam.InitiateStage(0); } if (skyBoxMaterial) { RenderSettings.skybox = skyBoxMaterial; } if (SCR_main.hCursor) { Cursor.visible = false; } SetState(10); SCR_gui.CreateScreenCover(0); }
void Awake() { character=GetComponent<SCR_character>(); attackReady=true; attackBufferAllowed=true; dir=new GameObject("rangedDir"); Transform dirTrans=dir.transform; dirTrans.parent=transform; dir.transform.localPosition=Vector3.zero; SND_shot=SCR_main.SetupSoundArray(transform,shotSound,true,true); }
public void StartUp() { character=GetComponent<SCR_character>(); //player=GameObject.FindWithTag ("Player").GetComponent<SCR_character>(); setMYPlayer (); CheckPlayerDistance(0); aggression=Mathf.Clamp(aggression,1,5); float aggressionMult=((aggression-1)*0.7f); attackFreq[0]=(2.8f-aggressionMult); attackFreq[1]=(attackFreq[0]+0.55f); if(alerted){ if(currentTargetEnemy!=null) character.SetRotAngle(currentTargetEnemy.transform.position); } else { character.SetPatrolSpeed(true); character.SetRandomRotAngle(); SetPatrolAction(0); actionCounter=(actionLimit*0.7f); } character.SetRotTarget(); transform.rotation=character.rotTarget; }
void Awake() { GameObject m=GameObject.Find ("MAIN"); main=m.GetComponent<SCR_main>(); music=m.GetComponent<SCR_music>(); if(stageMusic&&SCR_main.hMusic){ music.PlayMusic(stageMusic); } SCR_input.playerControlActive=false; pauseAllowed=false; paused=false; SCR_main.scoreRec=SCR_main.score; scoreRec=SCR_main.score; GameObject camInst=Instantiate(stageCamera,Vector3.zero,Quaternion.identity) as GameObject; GameObject spawnPointPlayer=GameObject.Find ("SpawnPointPlayer"); Vector3 playerPos=new Vector3(spawnPointPlayer.transform.position.x,0f,spawnPointPlayer.transform.position.z); if(main.playerSelect==true){ GameObject playerInst=Instantiate(main.playerObj1,playerPos,Quaternion.identity) as GameObject; Destroy(spawnPointPlayer); player=playerInst.GetComponent<SCR_character>(); SetupStageSize(); cam=camInst.GetComponent<SCR_camStage>(); cam.SetTarget(playerInst.transform); cam.InitiateStage(0); } else if(main.playerSelect==false){ GameObject playerInst=Instantiate(main.playerObj2,playerPos,Quaternion.identity) as GameObject; Destroy(spawnPointPlayer); player=playerInst.GetComponent<SCR_character>(); SetupStageSize(); cam=camInst.GetComponent<SCR_camStage>(); cam.SetTarget(playerInst.transform); cam.InitiateStage(0); } if(skyBoxMaterial){ RenderSettings.skybox=skyBoxMaterial; } if(SCR_main.hCursor){ Cursor.visible=false; } SetState (10); SCR_gui.CreateScreenCover(0); }