void ShootIt() { Vector3 currentTransform = cam.WorldToScreenPoint(currentObjects[globalIndex].transform.position); GunAim gunAim = (GunAim)GameObject.Find("GunAim").GetComponent("GunAim"); Component tempScript = currentObjects[globalIndex].GetComponent(typeof(MonoBehaviour)); float mouseY; float mouseX; if (tempScript.GetType().Equals(typeof(LightScript))) { mouseY = Screen.height * ASPECT_RATIO_MULTIPLIER_LIGHT; mouseX = currentTransform.x; } else { mouseY = Screen.height * ASPECT_RATIO_MULTIPLIER + Random.Range(-20f, 20f); mouseX = currentTransform.x + Random.Range(-10f, 10f); } float mouseZ = currentTransform.z; gunAim.mouseX = mouseX; gunAim.mouseY = mouseY; gunAim.mouseZ = mouseZ; StartCoroutine(ShootWaiter()); }
public void EyebotAttack() { if (!shotplayed) { lazer = true; StartCoroutine(PlayLazerSound()); } GunAim gunaimScript = eyebotGun.GetComponent <GunAim>(); gunaimScript.AimGun(target.transform); agent.isStopped = true; anim.SetBool("isAttacking", true); if (Vector3.Distance(target.transform.position, transform.parent.transform.position) > 2) { transform.parent.transform.LookAt(target.transform, Vector3.up); //Quaternion targetRotation = Quaternion.LookRotation(target.transform.position - transform.position); // float str = Mathf.Min(.5f * Time.deltaTime, 1); // transform.parent.transform.rotation = Quaternion.Lerp(transform.rotation, targetRotation, str); } if (!eyebotGun.activeSelf) { eyebotGun.SetActive(true); } if (Vector3.Distance(target.transform.position, transform.position) >= 15) { eyebotGun.SetActive(false); agent.isStopped = false; anim.SetBool("isAttacking", false); state = BasicAI.State.CHASE; } }
void TypeingCorrectionSecond(char c) { StringBuilder sb = new StringBuilder(); if (c == bullshitCharSetSecond[correctCharNumbSecond]) { GunAim gunAim = (GunAim)GameObject.Find("GunAim").GetComponent("GunAim"); float mouseX = Screen.width * 0.670f + UnityEngine.Random.Range(-30f, 30f); float mouseY = Screen.height * ASPECT_RATIO_MULTIPLIER + UnityEngine.Random.Range(-26f, 30f); gunAim.mouseX = mouseX; gunAim.mouseY = mouseY; GunShoot gunShoot = (GunShoot)GameObject.Find("GunShoot").GetComponent("GunShoot"); gunShoot.FireIt = true; if (correctCharNumbSecond > 0) { sb.Append("<color=#00FF00><b>"); sb.Append(secondPartString.Substring(0, correctCharNumbSecond)); } else { sb.Append("<color=#00FF00><b>"); } correctCharNumbSecond++; sb.Append(c); sb.Append("</b></color>"); sb.Append("<color=white>"); BadSubString = secondPartString.Substring(correctCharNumbSecond); sb.Append(BadSubString); sb.Append("</color>"); correctString = sb.ToString(); //Debug.Log(correctString); //description.text = correctString; scriptFlesh.npcName = correctString; scriptFlesh.IsCorrectType = true; } else { scriptFlesh.IsCorrectType = false; } }
void Update() { gunAim = GetComponentInParent <GunAim>(); if (FireIt && Time.time > nextFire) { nextFire = Time.time + fireRate; muzzleFlash.Play(); cartridgeEjection.Play(); anim.SetTrigger("Fire"); Vector3 rayOrigin = gunEnd.position; //Debug.Log("ez a fegyó vége"+ rayOrigin.ToString()); RaycastHit hit; if (Physics.Raycast(rayOrigin, gunEnd.forward, out hit, weaponRange)) { HandleHit(hit); } FireIt = false; } }
void Start() { anim = GetComponent <Animator> (); gunAim = GetComponentInParent <GunAim>(); }
private void Start() { gameController = GameObject.Find("GameController").GetComponent <GameController>(); gunFire = GetComponent <GunFire>(); gunAim = GetComponent <GunAim>(); }