// Token: 0x06001E3A RID: 7738 RVA: 0x00094BC4 File Offset: 0x00092DC4 private void CreateArrow(RaycastHit hit, Vector3 direction) { if (this._arrowProjectile && hit.collider != null) { Quaternion rotation = default(Quaternion); rotation = Quaternion.FromToRotation(Vector3.back, direction * -1f); ArrowProjectile arrowProjectile = UnityEngine.Object.Instantiate(this._arrowProjectile, hit.point, rotation) as ArrowProjectile; if (hit.collider.gameObject.layer == 18) { if (GameState.Current.Avatar.Decorator) { arrowProjectile.gameObject.transform.parent = GameState.Current.Avatar.Decorator.GetBone(BoneIndex.Hips); foreach (Renderer renderer in arrowProjectile.GetComponentsInChildren <Renderer>(true)) { renderer.enabled = false; } } } else if (hit.collider.gameObject.layer == 20) { arrowProjectile.SetParent(hit.collider.transform); } arrowProjectile.Destroy(15); } }
public void SpawnArrow(Agent attacker, Vector3 pos, Vector3 dir, float speed, float damage) { ArrowProjectile a = Cache.Get(); a.Init(attacker, pos, dir, speed, damage); ArrowsInAir.Add(a); }
public static ArrowProjectile Create(Vector3 position, Enemy target) { selfCache = Instantiate(Resources.Load <Transform>(typeof(ArrowProjectile).Name), position, Quaternion.identity).GetComponent <ArrowProjectile>(); selfCache.SetTarget(target); return(selfCache); }
public void SpawnArrow(Agent attacker, Vector3 pos, Vector3 dir, float speed, float damage) { //Debug.Log("Spawning arrow !! " + pos.ToString() + " " + dir.ToString() + " " + speed ); ArrowProjectile a = Cache.Get(); a.Init(attacker, pos, dir, speed, damage); ArrowsInAir.Add(a); }
public static ArrowProjectile CreateArrowProjectile(Vector3 position, Enemy enemy) { Transform xform = Instantiate(GameAssets.Instance.arrowProjectilePrefab, position, Quaternion.identity); ArrowProjectile arrowProjectile = xform.GetComponent <ArrowProjectile>(); arrowProjectile.SetTarget(enemy); Destroy(arrowProjectile.gameObject, arrowProjectile.maxLifetime); return(arrowProjectile); }
public static ArrowProjectile Create(Vector3 position, Enemy enemy, int damage) { Transform arrowTransform = Instantiate(GameAssets.Instance.pfArrowProjectile, position, Quaternion.identity); ArrowProjectile arrowProjectile = arrowTransform.GetComponent <ArrowProjectile>(); arrowProjectile.SetTarget(enemy); arrowProjectile.SetArrowDamage(damage); return(arrowProjectile); }
public IProjectile FireProjectile() { if (this.Target != null && this.Target.Exists && this.frameCount >= this.Speed) { this.frameCount = 0; Projectile projectile = null; if (Math.Abs(this.lastAngle - this.towerAngle) < 1) { switch (this.projectileType) { case ProjectileSelection.ArrowProjectile: projectile = new ArrowProjectile( this.Coordinates.X, this.Coordinates.Y, this.Target, this.Damage); break; case ProjectileSelection.FireProjectile: projectile = new FireProjectile( this.Coordinates.X, this.Coordinates.Y, this.Target, this.Damage); break; case ProjectileSelection.FreezeProjectile: projectile = new FreezeProjectile( this.Coordinates.X, this.Coordinates.Y, this.Target, this.Damage); break; case ProjectileSelection.SniperProjectile: projectile = new SniperProjectile( this.Coordinates.X, this.Coordinates.Y, this.Target, this.Damage); break; } return(projectile); } } else { this.frameCount++; } return(null); }
public static ArrowProjectile Create(Vector3 position, Enemy enemy) { Transform pfArrowProjectile = Resources.Load <Transform>("pfArrowProjectile"); Transform arrowTransform = Instantiate(pfArrowProjectile, position, Quaternion.identity); ArrowProjectile arrowProjectile = arrowTransform.GetComponent <ArrowProjectile>(); arrowProjectile.SetTarget(enemy); return(arrowProjectile); }
private void HandleShooting() { if (_target != null) { _shootTargetTimer -= Time.deltaTime; if (_shootTargetTimer <= 0) { _shootTargetTimer += shootTargetTime; ArrowProjectile.CreateArrowProjectile(spawnPoint.position, _target); } } }
private void HandleShooting() { shootTimer -= Time.deltaTime; if (shootTimer <= 0f) { shootTimer += shootTimerMax; if (targetEnemy != null) { ArrowProjectile.Create(projectileSpawnPosition, targetEnemy); } } }
private void HandleShooting() { _shootTimer -= Time.deltaTime; if (_shootTimer <= 0f) { _shootTimer = shootTimerMax; if (_targetEnemy) { ArrowProjectile.Create(_projectileSpawnPosition.position, _targetEnemy); } } }
void OnTriggerEnter(Collider collider) { ArrowProjectile arrow = collider.gameObject.GetComponent <ArrowProjectile>(); if (arrow != null) { owner.OnGoodBlock(arrow); //gameObject.SetActive(false); //IsActive = false; Destroy(collider.gameObject); } }
public virtual void OnCollisionEnter(Collision collision) { if (collision.transform.CompareTag("Arrow")) { Transform arrow = collision.transform; ArrowProjectile arrowScript = arrow.GetComponent <ArrowProjectile>(); DamageDisplay.Create(transform.position + Vector3.up * 2f, arrowScript.damage, DamageType.CRITICAL); agent.Move(collision.transform.forward.normalized * 0.1f); //Vector3 result = collision.transform.forward + transform.forward * -1; //rb.AddForce(result.normalized * 50f, ForceMode.Impulse); //rb.AddExplosionForce(50.0f, collision.transform.GetComponent<ArrowProjectile>().head.position, 2f); } }
/// <summary> /// Creates an arrow and makes it fly in the given direction /// </summary> /// <param name="Owner">The FirstPersonMover that should be considered the owner of the arrow</param> /// <param name="StartPosition"></param> /// <param name="MoveDir"></param> /// <param name="fireSpreadDefinition"></param> /// <param name="BladeWidth"></param> /// <param name="MakeFlyBySound"></param> /// <param name="RotationZ"></param> /// <returns>The fired arrow</returns> public static ArrowProjectile CreateFlaming(FirstPersonMover Owner, Vector3 StartPosition, Vector3 MoveDir, FireSpreadDefinition fireSpreadDefinition, float BladeWidth = 1f, bool MakeFlyBySound = false, float RotationZ = 0f) { if (Owner == null) { return(null); } ArrowProjectile arrow = Create(Owner, StartPosition, MoveDir, BladeWidth, MakeFlyBySound, RotationZ); arrow.SetOnFire(fireSpreadDefinition); return(arrow); }
private void MakeArrow() { if (playerInventory.currentMagic > 0) { Vector2 temp = new Vector2(animator.GetFloat("moveX"), animator.GetFloat("moveY")); // get the current direction of player standin ArrowProjectile arrow = Instantiate(projectile, spawnPoint.position, Quaternion.identity).GetComponent <ArrowProjectile>(); arrow.Setup(temp, ChooseArrowDirection()); playerInventory.ReduceMagic(arrow.magicCost); // magicCost = projectile.GetComponent<PlayerProjectiles>().magicCost; // magicManager.DecreaseMagic(magicCost); reduceMagic.Raise(); } }
private void Shoot() { if (targetEnemy != null) { if (Time.timeSinceLevelLoad > shootTimer) { ArrowProjectile.Create(projectileSpawnPoint .transform.position, targetEnemy); shootTimer = Time.timeSinceLevelLoad + shootTimerOffset; } } }
public bool Return(ArrowProjectile arrow) { int len = Cache.Count; for (int i = 0; i < len; i++) { if (Cache[i] == arrow) { Mission.Instance.StartCoroutine(Hide(arrow.GameObject)); return(true); } } return(false); }
private void HandleShooting() { shootTimer -= Time.deltaTime; if (shootTimer <= 0f) { projectileSpawnPosition = transform.Find("ProjectileSpawnPosition").position; shootTimer += shootTimerMax; if (targetEnemy != null) { ArrowProjectile.Create(projectileSpawnPosition, targetEnemy, arrowDamage); } } }
IEnumerator ThrowProjectile(GameObject prefab) { GameObject projectile = Instantiate(prefab); ArrowProjectile arrowProjectile = projectile.GetComponent <ArrowProjectile>(); Vector3 direction = calculateDirection(arrowProjectile.force); projectile.transform.position = fireTransform.position + direction; projectile.transform.forward = direction; //Wait for the position to update yield return(null); arrowProjectile.Fire(direction); }
/// <summary> /// Creates an arrow and makes it fly in the given direction /// </summary> /// <param name="Owner">The FirstPersonMover that should be considered the owner of the arrow</param> /// <param name="StartPosition"></param> /// <param name="MoveDir"></param> /// <param name="BladeWidth"></param> /// <param name="MakeFlyBySound"></param> /// <param name="RotationZ"></param> /// <returns>The fired arrow</returns> public static ArrowProjectile Create(FirstPersonMover Owner, Vector3 StartPosition, Vector3 MoveDir, float BladeWidth = 1f, bool MakeFlyBySound = false, float RotationZ = 0f) { if (Owner == null) { return(null); } ArrowProjectile arrow = ProjectileManager.Instance.CreateInactiveArrow(false); arrow.transform.SetParent(LevelSpecificWorldRoot.Instance.transform, true); arrow.SetBladeWidth(BladeWidth); arrow.StartFlying(StartPosition, MoveDir, MakeFlyBySound, Owner, false, BoltNetwork.serverFrame, RotationZ); return(arrow); }
public override void Init() { GameObject g; ArrowProjectile a; for (int i = 0; i < MaxCount; i++) { g = GameObject.Instantiate(Prefab) as GameObject; g.transform.parent = AutoElementManager.Instance.transform; g.name = g.name + i.ToString(); g.SetActive(false); g.layer = cache_free; a = new ArrowProjectile(g); Cache.Add(a); } }
public void Init(GameObject prefab, int count) { GameObject g; ArrowProjectile a; for (int i = 0; i < count; i++) { g = GameObject.Instantiate(prefab) as GameObject; g.name = g.name + i.ToString(); g.SetActiveRecursively(false); g.layer = cache_free; a = new ArrowProjectile(g); Cache.Add(a); } }
/// <summary> /// Called when an <see cref="ArrowProjectile"/> is created /// </summary> /// <param name="arrow">The created <see cref="ArrowProjectile"/></param> public virtual void OnArrowProjectileCreated(ArrowProjectile arrow) { }
/// <summary> /// Called when an <see cref="ArrowProjectile"/> starts moving /// </summary> /// <param name="arrow"></param> public virtual void OnArrowProjectileStartedMoving(ArrowProjectile arrow) { }
/// <summary> /// Called every frame since the given <see cref="ArrowProjectile"/> was created /// </summary> /// <param name="arrow"></param> public virtual void OnArrowProjectileUpdate(ArrowProjectile arrow) { }
/// <summary> /// Called when the given <see cref="ArrowProjectile"/> is destroyed in any way /// </summary> /// <param name="arrow"></param> public virtual void OnArrowProjectileDestroyed(ArrowProjectile arrow) { }
void UpdateDecisionVars() { tree.SetGlobalVar("StageSize", GameMode.main.stage.currentSize); tree.SetGlobalVar("AliveCount", GameMode.main.aliveCount); tree.SetGlobalVar("ActionEnum", (float)character.currentAction); tree.SetGlobalVar("ActionCooldown", character.actionTimer); distanceFromCentre = Vector3.Distance(GameMode.main.stage.transform.position, character.transform.position); distanceFromEdge = Mathf.Max(0, GameMode.main.stage.currentSize - distanceFromCentre); tree.SetGlobalVar("CentreDist", distanceFromCentre); tree.SetGlobalVar("EdgeDist", distanceFromEdge); float closestCharDist = 99999.0f; closestCharacter = null; float closestArrowDist = 99999.0f; closestArrow = null; nearbyCharacters.Clear(); foreach (Character other in GameMode.main.characters) { if (other != character) { if (other.isAlive) { float distance = Vector3.Distance(other.transform.position, character.transform.position); // This is the closest char if (closestCharacter == null || distance < closestCharDist) { closestCharacter = other; closestCharDist = distance; } // Player is nearby if (distance < nearCharacterRange) { nearbyCharacters.Add(other); } } if (other.currentProjectile != null) { float distance = Vector3.Distance(other.currentProjectile.transform.position, character.transform.position); // This is the closest arrow if (closestArrow == null || distance < closestArrowDist) { closestArrow = other.currentProjectile; closestArrowDist = distance; } } } } tree.SetGlobalVar("ClosestEnemy", closestCharDist); tree.SetGlobalVar("ClosestArrow", closestArrowDist); tree.SetGlobalVar("NearbyEnemies", nearbyCharacters.Count); }
/// <summary> /// Called when this character has successfully blocked a shot /// </summary> public void OnGoodBlock(ArrowProjectile arrow) { blockCount++; }