void Update() { if (teleporting) { Vector3 targetPosition = teleportTarget.TeleportPosition; float p = (Time.time - tpTimeStarted) / playerConfig.TeleportDuration; Vector3 lposition = Vector3.Lerp(tpStartPosition, targetPosition, p); lposition.y = tpStartPosition.y; transform.position = lposition; if (p >= 0.95f) { Vector3 end = teleportTarget.TeleportPosition; end.y = transform.position.y; transform.position = end; teleporting = false; } } else if (playerHandConfig.hasFire) { if (teleportTarget != null) { teleportArea.SetActive(false); teleportTarget = null; } } else { CheckTeleportationPossibilities(); } ProcessInput(); }
// called instead of Start() due to prefab Cloning/Reusing protected override void Initialize() { // Just Assigning refrences spawnManager = FindObjectOfType <SpawnManager>(); agent = GetComponent <NavMeshAgent>(); fire = GetComponent <FireSource>(); zombie_audio = GetComponent <AudioSource>(); anim = GetComponentInChildren <Animator>(); hitbox = gameObject.GetComponent <CapsuleCollider>(); fireHitbox = fire.GetComponent <CapsuleCollider>(); // Health and Speed defined on Prefab in editor setHealth(MAX_HEALTH); agent.speed = SPEED; // set dafault bool values dead = false; isAttacking = false; hasDealtDamage = false; fire.isBurning = false; agent.isStopped = false; // Assign torch object reference array torches = spawnManager.torches; // Send Navmesh Agent on its merry way to the closest torch target = FindTarget(); SetDestination(); // May not be necessary: resets AC upon spawn if (!anim.isInitialized) { anim.Rebind(); } }
protected override void Initialize() { Debug.Log("Initialized!"); setHealth(MAX_HEALTH); dead = false; isAttacking = false; //removeArrows(); anim = GetComponentInChildren <Animator>(); //goal = FindObjectOfType<Player>().gameObject.transform.position; goal = new Vector3(0, 0, 0); spawnManager = FindObjectOfType <SpawnManager>(); agent = GetComponent <NavMeshAgent>(); fire = GetComponent <FireSource>(); if (!anim.isInitialized) { anim.Rebind(); } fire.isBurning = false; agent.speed = SPEED; agent.destination = goal; agent.isStopped = false; //ResetAnimations(); if (Random.Range(0, 2) > 2) { anim.SetBool("OtherWalk", true); } else { anim.SetBool("OtherWalk", false); } }
private void Start() { fireSource = GetComponent <FireSource>(); GameObject AudioAssets = gameObject.FindChild("AudioAssets"); StudioEventEmitter[] array = AudioAssets.GetComponents <StudioEventEmitter>(); for (int i = 0; i < array.Length; i++) { StudioEventEmitter emitter = array[i]; switch (i) { case 0: sfx_laserLoop = emitter; break; case 1: sfx_oneShot = emitter; break; } } GameObject SparkEmit = gameObject.FindChild("SparkEmit"); fxControl = SparkEmit.GetComponent <VFXController>(); fxLight = SparkEmit.GetComponentInChildren <Light>(); playerIKTarget = Player.main.armsController.lookTargetTransform.GetComponent <AimIKTarget>(); }
private void EnsureInit() { if (pickupable != null) { return; } pickupable = GetComponent <Pickupable>(); itemAtts = GetComponent <ItemAttributesV2>(); registerTile = GetComponent <RegisterTile>(); fireSource = GetComponent <FireSource>(); reagentContainer = GetComponent <ReagentContainer>(); if (reagentContainer != null) { reagentContainer.OnSpillAllContents.AddListener(ServerEmptyWelder); } damageOff = itemAtts.ServerHitDamage; //leftHandOriginal = itemAtts.inHandReferenceLeft; //rightHandOriginal = itemAtts.inHandReferenceRight; leftHandFlame = leftHandOriginal + 4; rightHandFlame = rightHandOriginal + 4; }
void CheckFirePossibilities() { RaycastHit hit; RaycastHit burnHit; Vector3 endPoint = transform.TransformDirection(Vector3.forward); bool rayHitSomething = CastTorchCheckRay(endPoint, out hit); bool rayHitBurnTarget = CastBurnCheckRay(endPoint, out burnHit); if (rayHitSomething && !rayHitBurnTarget) { //Vector3 point = hit.point; targetFireSource = GetInteractableFireSource(hit); } else if (rayHitSomething && rayHitBurnTarget && burnHit.distance > hit.distance) { targetFireSource = GetInteractableFireSource(hit); } else { if (previouslyHitTorch != null) { previouslyHitTorch.SetMaterial(fireConfig.TorchDefaultMaterial); } targetFireSource = null; /*Vector3 point = transform.position + transform.forward * fireConfig.MaxDistance; * point.y = 0f;*/ } DebugRayCast(hit, rayHitSomething); }
//------------------------------------------------- void OnCollisionEnter(Collision collision) { if (inFlight) { Rigidbody rb = GetComponent <Rigidbody>(); float rbSpeed = rb.velocity.sqrMagnitude; bool canStick = (targetPhysMaterial != null && collision.collider.sharedMaterial == targetPhysMaterial && rbSpeed > 0.2f); if (travelledFrames < 2 && !canStick) { // Reset transform but halve your velocity transform.position = prevPosition - prevVelocity * Time.deltaTime; transform.rotation = prevRotation; Vector3 reflfectDir = Vector3.Reflect(arrowHeadRB.velocity, collision.contacts[0].normal); arrowHeadRB.velocity = reflfectDir * 0.25f; shaftRB.velocity = reflfectDir * 0.25f; travelledFrames = 0; return; } if (glintParticle != null) { glintParticle.Stop(true); } // Only play hit sounds if we're moving quickly if (rbSpeed > 0.1f) { hitGroundSound.Play(); } FireSource arrowFire = gameObject.GetComponentInChildren <FireSource>(); FireSource fireSourceOnTarget = collision.collider.GetComponentInParent <FireSource>(); if (arrowFire != null && arrowFire.isBurning && (fireSourceOnTarget != null)) { if (!hasSpreadFire) { collision.collider.gameObject.SendMessageUpwards("FireExposure", gameObject, SendMessageOptions.DontRequireReceiver); hasSpreadFire = true; } } if (canStick) { StickInTarget(collision, travelledFrames < 2); } // Player Collision Check (self hit) if (Player.instance && collision.collider == Player.instance.headCollider) { Player.instance.PlayerShotSelf(); } } }
public void OnSceneGUI() { fireSource = this.target as FireSource; debugRenderer = fireSource.GetComponentInChildren <SpriteRenderer>(); Vector3 scale = new Vector3(fireSource.Range * 2, fireSource.Range * 2, 1f); Vector3 pos = debugRenderer.transform.position; pos.y = 0.1f; debugRenderer.transform.position = pos; debugRenderer.transform.localScale = scale; }
public override void Initialize() { Flame = new FireSource(Game, this); Flame.Offset = new Vector2(23, 177); //Flame.Origin = Origin + Position; Flame.fireWidth = 55; Flame.fireMaxVelocity = 50; Game.Components.Add(Flame); base.Initialize(); Origin = new Vector2(Texture.Width / 2, Texture.Height / 2); Scale = Shuttle.Scale; }
public override void Shoot() { TimeSinceFire = 0; FireSource.Play(); CurrentMag--; Ray ray = Camera.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0)); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { if (hit.transform.tag == "zombie") { zombieHealth.DealDamage("Rifle", hit.transform.gameObject, Vector3.Distance(ray.origin, hit.transform.position)); } } }
void DrawTeleportArea(Vector3 endPoint) { teleportTarget = GetTeleportableFireSource(endPoint); Vector3 teleportAreaPosition; if (teleportTarget != null) { teleportAreaPosition = teleportTarget.TeleportPosition; } else { teleportAreaPosition = endPoint; } teleportAreaPosition.y = playerConfig.TeleportAreaPrefab.transform.position.y; teleportArea.transform.position = teleportAreaPosition; teleportArea.SetActive(teleportTarget != null); }
public override void Shoot() { TimeSinceFire = 0; FireSource.Play(); CurrentMag--; for (int i = 0; i < ProjectileCount; i++) { float x = Random.Range(0.4f, 0.6f); float y = Random.Range(0.4f, 0.6f); Ray ray = Camera.ViewportPointToRay(new Vector3(x, y, 0)); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { if (hit.transform.tag == "zombie") { zombieHealth.DealDamage("Shotgun", hit.transform.gameObject, Vector3.Distance(ray.origin, hit.transform.position)); } } } }
public override void Initialize() { keyboard = new KeyboardController(Game); Game.Components.Add(keyboard); Tank = new ShuttleTank(Game, this); FirstRocket = new ShuttleRocket(Game, this); SecondRocket = new ShuttleRocket(Game, this); // Rocket - Tank - Rocket Game.Components.Add(FirstRocket); Game.Components.Add(Tank); Game.Components.Add(SecondRocket); Flame = new FireSource(Game, this); FireParticle.color = Color.White; Flame.Offset = new Vector2(-11, 116); Flame.fireWidth = 2; Game.Components.Add(Flame); base.Initialize(); // Smoke in front of rockets and tank smokeSource = new SmokeSource(Game); smokeSource.Initialize(); SmokeParticle.color = Color.White; smokeSource.SmokeOrigin = new Vector2(SmokeParticle.texture.Width / 2, SmokeParticle.texture.Height / 2); smokeSource.Position = new Vector2(GraphicsDevice.Viewport.Width / 2 + 55, GraphicsDevice.Viewport.Height - 50); smokeSource.DrawOrder = Int32.MaxValue; Game.Components.Add(smokeSource); Direction.Y = 1; Origin = new Vector2(Texture.Width / 2f, Texture.Height / 2f); //Rotation = (float)(Math.PI / 2); Scale = new Vector2(0.65f); Position = new Vector2(GraphicsDevice.Viewport.Width / 2, 0); //GraphicsDevice.Viewport.Height + Texture.Width); //Effect = SpriteEffects.FlipVertically; }
static int SortByDistance(FireSource sourceA, FireSource sourceB) { return(sourceA.distanceToCursor.CompareTo(sourceB.distanceToCursor)); }
public void AddFireSource(FireSource fireSource) { fireSources.Add(fireSource); }
private void Awake() { spriteHandler = GetComponentInChildren <SpriteHandler>(); fireSource = GetComponent <FireSource>(); pickupable = GetComponent <Pickupable>(); }
private void Awake() { fireSource = GetComponent <FireSource>(); pickupable = GetComponent <Pickupable>(); }
private void Awake() { fireSource = GetComponent <FireSource>(); pickupable = GetComponent <Pickupable>(); lightControl = GetComponent <ItemLightControl>(); }