public void Load() { m_dicProjectileInfo.Clear(); TextAsset TXTFile = (TextAsset)Resources.Load("Config/Projectile"); string strText = TXTFile.text.Replace("\r\n", "|"); string[] split = strText.Split('|'); int nAmount = split.Length; int i; for (i = 0; i < nAmount; ++i) { ProjectileInfo stInfo = new ProjectileInfo(); string[] spInfos = split[i].Split(','); if (spInfos.Length != 4) { Debug.Log("ProjectileConfig Load spInfos.Length != 4\n"); } else { stInfo.strName = spInfos[0]; stInfo.nSpeed = int.Parse(spInfos[1]); stInfo.strEffectName = spInfos[2]; stInfo.strGroundEffect = spInfos[3]; m_dicProjectileInfo[stInfo.strName] = stInfo; } } }
private static Projectile ConfigureProjectile(ProjectileInfo info, ref Projectile projectile, int currentProjectile = 0) { switch (info.spreadType) { case ProjectileSpreadType.None: break; case ProjectileSpreadType.Random: float error = Random.Range(info.error, -info.error); projectile.transform.rotation = Quaternion.Euler(projectile.transform.rotation.x, error, projectile.transform.rotation.z); break; case ProjectileSpreadType.EvenlySpread: float errorRange = info.error; float percentOfRange = info.projectileCount / errorRange; float offset = currentProjectile == 0 && info.projectileCount.IsOdd() ? 0 : (currentProjectile + 1) * percentOfRange; projectile.transform.rotation = Quaternion.Euler(projectile.transform.rotation.x, offset, projectile.transform.rotation.z); break; } return(projectile); }
public void SetProjectileInfo(ProjectileInfo info) { type = info.type; renderer.material = info.projectileMaterial; rb.mass = info.mass; transform.localScale = Vector3.one * info.baseSize * transform.localScale.x / transform.lossyScale.x; }
private void Spawn(ProjectileInfo info, Vector3 position, Vector3 direction, string target, CharacterState own) { if (count == capacity) { return; } const float angle = 15f; Quaternion rot = Quaternion.identity; for (int i = 0; i < info.spreadAmount; i++) { if (count == capacity) { break; } projectiles[count].position = position; projectiles[count].direction = rot * direction; projectiles[count].distance = 0f; projectiles[count].info = info; projectiles[count].target = target; projectiles[count].own = own; count++; rot = Quaternion.AngleAxis(Random.Range(-angle, angle), Vector3.up) * Quaternion.AngleAxis(Random.Range(-angle, angle), Vector3.right) * Quaternion.AngleAxis(Random.Range(-angle, angle), Vector3.forward); } }
public static Projectile CreateProjectile(ProjectileInfo info, Constants.EffectOrigin location, GameObject source, int currentProjectile = 0) { Vector3 spawnPoint; Quaternion spawnRot = Quaternion.identity; if (location != Constants.EffectOrigin.MousePointer) { Transform point = source.Entity().effectDelivery.GetOriginPoint(location); spawnPoint = point.position; spawnRot = point.rotation; } else { spawnPoint = source.transform.position; } Projectile loadedProjectile = LoadAndSpawnProjectile(info.prefabName, spawnPoint, spawnRot); if (loadedProjectile == null) { return(null); } return(ConfigureProjectile(info, ref loadedProjectile, currentProjectile)); }
private void OnTriggerEnter(Collider other) { if (other.tag == "HurtBox") { if (other.gameObject.layer == 10) //if hurtbox is on enemy layer { Enemy enemy = other.gameObject.transform.root.GetComponentInChildren <Enemy>(); float damage = enemy.currentAttack.damage; HurtPlayer(damage); //will poison the player for a while if the attack poisons if (enemy.currentAttack.status == PlayerManager.StatusEffect.poisoned) { if (Random.Range(0, 1f) <= enemy.currentAttack.statusChance) { //Player becomes poisoned PlayerManager.Instance.currentStatus = PlayerManager.StatusEffect.poisoned; poisonTimer = 10.0f; poisonPainTimer = 0; PlayerManager.Instance.playerTex.SetColor("_Tint", new Color(0, 1f, 0.75f, 1f)); PlayerManager.Instance.playerTexTrans.SetColor("_Tint", new Color(0, 1f, 0.75f, 1f)); PlayerManager.Instance.poisonBubbles.Play(); } } } else if (other.gameObject.layer == 11) //if hurtbox is on enemyProjectile layer { ProjectileInfo projectile = other.GetComponentInParent <ProjectileInfo>(); HurtPlayer(projectile.damage); } } }
public ShooterInfo(MechaType mechaType, float fireInterval, float maxRange, ProjectileInfo projectileInfo) { MechaType = mechaType; FireInterval = fireInterval; MaxRange = maxRange; ProjectileInfo = projectileInfo; }
private void OnProjectileSpawned(int projectileOwnerIndex, int projectileIndex, int projectileType, Vector3 spawnPosition, Vector3 spawnRotation, bool isControlledByServer) { PlayerData myPlayerData = FindPlayerDataWithShipIndex(projectileOwnerIndex); ProjectileInfo newProjectileInfo = new ProjectileInfo(); newProjectileInfo.projectileOwnerIndex = projectileOwnerIndex; newProjectileInfo.projectileIndex = projectileIndex; newProjectileInfo.projectileType = projectileType; myPlayerData.spawnedProjectiles.Add(newProjectileInfo); if (projectileType == 0) { myPlayerData.projectileTypeZeroSpawns++; } else if (projectileType == 1) { myPlayerData.projectileTypeOneSpawns++; } else if (projectileType == 2) { myPlayerData.projectileTypeTwopawns++; } else if (projectileType == 3) { myPlayerData.projectileTypeThreeSpawns++; } }
// it is assumed the current projectile is a generic projectile with an empty reference behaviour to fill up public void Clone(Projectile p_projectile, ProjectileInfo p_projectileInfo, List <ProjectileBehaviour> p_extraBehaviours) { p_projectile.LoadComponents(); LoadComponents(); SpriteRenderer render = m_render; BoxCollider2D collider = m_boxCollider; render.sprite = p_projectile.m_render.sprite; collider.size = p_projectile.m_boxCollider.size; collider.offset = p_projectile.m_boxCollider.offset; // this will overwrite any assignment done to this projectile beforehand p_projectile.Copy(typeof(Projectile), gameObject); m_render = render; m_boxCollider = collider; m_info = p_projectileInfo; m_behaviourManager = GetComponent <BehaviourManager>(); m_behaviourManager.m_behaviours = new Dictionary <ProjectileBehaviour, bool>(); foreach (ProjectileBehaviour behaviour in m_info.m_behaviours) { m_behaviourManager.m_behaviours.Add(behaviour, false); } foreach (ProjectileBehaviour behaviour in p_extraBehaviours) { m_behaviourManager.m_behaviours.Add(behaviour, false); } m_original = p_projectile; }
private void OnTriggerEnter(Collider other) { if (other.tag == "HurtBox") { if (other.gameObject.layer == 10) //if hurtbox is on enemy layer { EnemyLogic enemy = other.GetComponentInParent <EnemyLogic>(); if (enemy.currentAttack.getAttacking() && enemy.currentAttack.getCanHurt()) { PlayerManager.Instance.currentHealth -= enemy.currentAttack.damage; Vector3 direction = transform.position - other.transform.root.position; direction.y = 100.0f; direction *= 5.0f * enemy.currentAttack.knockbackMult; float time = 0.2f; object[] array = { direction, time }; SendMessage("PlayerKnockback", array); } } else if (other.gameObject.layer == 11) //if hurtbox is on enemyProjectile layer { ProjectileInfo projectile = other.GetComponentInParent <ProjectileInfo>(); PlayerManager.Instance.currentHealth -= projectile.damage; Vector3 direction = transform.position - other.transform.root.position; direction.y = 100.0f; direction *= 5.0f * projectile.knockbackMult; float time = 0.2f; object[] array = { direction, time }; SendMessage("PlayerKnockback", array); } } }
IEnumerator Spawn() { SpawnableObject.CurrentNumberOfObjects = 0; while (amountOfObjectsToSpawn > 0) { yield return(new WaitForSeconds(timeBetweenSpawns)); int objectNumber = Random.Range(0, objectsForSpawn.Length); Vector3 randomPosition = Vector3.Lerp(leftBorder.position, rightBorder.position, Random.Range(0.0f, 1.0f)); Quaternion randomRotation = Quaternion.Euler(new Vector3(0.0f, 0.0f, Random.Range(0.0f, 360.0f))); GameObject newObject = Instantiate(objectsForSpawn[objectNumber].spawnObjectPrefab, randomPosition, randomRotation); newObject.transform.localScale = Vector3.one * objectsForSpawn[objectNumber].objectSize; Rigidbody objectRB = newObject.GetComponent <Rigidbody>(); objectRB.mass = objectsForSpawn[objectNumber].objectMass; objectRB.drag = objectsForSpawn[objectNumber].objectDrag; if (types.Length > 0) { ProjectileInfo info = types[Random.Range(0, types.Length)]; newObject.GetComponent <SpawnableObject>().ApplyType(info); } amountOfObjectsToSpawn--; } StartCoroutine(WaitForGameWon()); }
public void CreateProjectile(ProjectileInfo pi) { Vector3 AimPoint = pi.ProjectileAimDirection; if (pi.AimTowardsTarget) { Vector3 tp = pi.ProjectileAimDirection; if (GetComponent <OffenseAI>() != null && GetComponent <OffenseAI>().CurrentTarget != null) { tp = GetComponent <OffenseAI>().CurrentTarget.transform.position; Debug.Log("Targeting point: " + tp); } Vector3 newAimPoint = Vector2.ClampMagnitude(new Vector3(tp.x - transform.position.x, tp.y - transform.position.y), 1.0f); Debug.Log("Aim point: " + newAimPoint); Vector3 ViewVec = new Vector2(1f, 0f); if (GetComponent <Orientation>().FacingLeft) { ViewVec = new Vector3(-1f, 0f); } Debug.Log("Angle to point: " + Vector2.Angle(ViewVec, newAimPoint)); if (Vector2.Angle(ViewVec, newAimPoint) < pi.MaxAngle) { AimPoint = new Vector2(Mathf.Abs(newAimPoint.x), newAimPoint.y); } } Projectile p = GetComponent <HitboxMaker>().CreateProjectile(pi.Projectile, pi.ProjectileCreatePos, AimPoint, pi.ProjectileSpeed, pi.Damage, pi.Stun, pi.HitboxDuration, pi.Knockback, true, pi.Element); p.PenetrativePower = pi.PenetrativePower; }
public void InitializeProjectile(ProjectileInfo projectileInfo, Vector3 startPosition) { this.projectileInfo = projectileInfo; transform.position = startPosition; transform.LookAt(transform.position + projectileInfo.fireDirection); projectileSphereCollider.radius = projectileInfo.colliderRadius; }
public void SpawnProjectile() { GameObject projectile = projectilePool.GetNext(); //Scaling constants for unit compatibility float projScale = 0.5f; //Projectile size scale float velocityScale = 1.5f; //Muzzle velocity scale Vector3 shootFrom = GetBarrel().position; ProjectileInfo info = projectile.GetComponent <ProjectileInfo>(); info.startPosition = shootFrom; info.weaponInfo = weaponInfo; AmmoTypeInfo ammoTypeInfo = info.GetComponent <AmmoTypeInfo>(); //Projectile dimensions float projDiameter = ammoTypeInfo.caliber * projScale; float projLength = projDiameter * (ammoTypeInfo.caliberToLength * 2.0f); projectile.transform.position = shootFrom; projectile.transform.localScale = new Vector3(projDiameter, projLength, projDiameter); Rigidbody body = projectile.GetComponent <Rigidbody>(); Vector3 direction = new Vector3(0, 0, weaponInfo.muzzleVelocity * velocityScale); projectile.transform.rotation = gameObject.transform.rotation * Quaternion.Euler(90.0f, 0.0f, 0.0f); body.velocity = gameObject.transform.rotation * direction; AudioSource audioSource = gameObject.GetComponent <AudioSource>(); AudioClip fireClip = ammoTypeInfo.soundOnFire; audioSource.PlayOneShot(fireClip); }
public void InitFromProjectileInfo(ProjectileInfo pi, GameObject parent, FactionHolder fh = null) { float deg = Mathf.Deg2Rad * parent.transform.rotation.eulerAngles.y; if (pi.AimTowardsTarget) { } else { transform.localPosition = transform.position + Orientation.OrientToVectorZ(pi.ProjectileCreatePos, deg); } AimPoint = Orientation.OrientToVectorZ(pi.ProjectileAimDirection, deg); ProjectileSpeed = pi.ProjectileSpeed; SetAimPoint(AimPoint); PenetrativePower = pi.PenetrativePower; Damage = pi.Damage; Stun = pi.Stun; Duration = pi.HitboxDuration; AddElement(pi.Element); Knockback = Orientation.OrientToVectorZ(pi.Knockback, deg); hitCallback = pi.hitCallback; if (fh != null) { fh.SetFaction(gameObject); } Creator = parent; Init(); }
public void ApplyDamage(ProjectileInfo projectileInfo, Unit unit) { if (unit.IsAlive && projectileInfo.Sender != unit) { unit.Stats.CurrentHealth.Value -= projectileInfo.Damage; DamageTaken?.Invoke(unit); } }
public GameObject Spawn(ProjectileInfo info, float angle) { Quaternion projectileRotation = MathfExt.QuaternionFromAngle2D(angle); GameObject projectile = ProjectileFactory.Create(info.ProjectileType, transform.position, projectileRotation, info.CollisionLayer); projectile.GetComponent <IProjectileLogic>().OnInitialize(info, projectileRotation * Vector2.up); return(projectile); }
public void SetProjectileInfo(ProjectileInfo info) { projectileInfo = info; if (currentProjectile.transform.parent == placeForProjectile) { currentProjectile.SetProjectileInfo(projectileInfo); } }
/// <summary> /// Change's projectile's rigidbody's velocity based on it's adjusted velocity vector and base speed. /// </summary> void SetVelocity() { ProjectileInfo pi = GetComponent <ProjectileInfo>(); if (pi != null) { GetComponent <Rigidbody>().velocity = (transform.forward * pi.Speed) + adjustedVelocity; } }
/// <inheritdoc /> public int CreateProjectile(ProjectileInfo projectile) { ILivingEntity livingEntity = projectile.Owner; int projectileId = livingEntity.Battle.LastProjectileId++; livingEntity.Battle.Projectiles.Add(projectileId, projectile); return(projectileId); }
public void ActivateProjectile(string projectileName, Transform parentTransform, Vector3 direction) { projectileObjectList[activatedProjectileNumber].SetActive(true); ProjectileInfo projectileInfo = projectileDictionary[projectileName]; projectileObjectList[activatedProjectileNumber].GetComponent <Projectile>().Set(activatedProjectileNumber, projectileInfo.speed, projectileInfo.damage, projectileInfo.distance, parentTransform, direction, DataContainer.projectileAtlas.GetSprite(projectileName)); activatedProjectileNumber++; }
private static Projectile ConfigureProjectile(ProjectileInfo info, ref Projectile projectile, int currentProjectile = 0) { switch (info.spreadType) { case ProjectileSpreadType.None: break; case ProjectileSpreadType.Random: float error = Random.Range(info.error, -info.error); projectile.transform.rotation = Quaternion.Euler( projectile.transform.rotation.x, projectile.transform.rotation.y, error); //projectile.transform.rotation = Quaternion.Euler(projectile.transform.rotation.x, error, projectile.transform.rotation.z); break; case ProjectileSpreadType.EvenlySpread: float errorRange = info.error; float percentOfRange = info.projectileCount / errorRange; float newOffset = /*(currentProjectile + 1) +*/ info.error /** percentOfRange*/; if (currentProjectile == 0 && info.projectileCount.IsOdd()) { newOffset = 0f; } if (currentProjectile.IsOdd()) { //newOffset = (currentProjectile - 1) + info.error; newOffset *= -1f; } float offset = currentProjectile == 0 && info.projectileCount.IsOdd() ? 0 : (currentProjectile) * percentOfRange; Debug.Log((newOffset) + " is the current offset"); projectile.transform.rotation = Quaternion.Euler( projectile.transform.rotation.x, projectile.transform.rotation.y, newOffset); //projectile.transform.rotation = Quaternion.Euler(projectile.transform.rotation.x, offset, projectile.transform.rotation.z); break; } return(projectile); }
public IEnumerator Fire(Robot caster, Vector3 dir, bool isReallyFire) { #region Wait for Pre delay state = State.PreDelay; // 20 02 09 내 캐릭터의 경우, preDelay + Rtt 만큼 더 기다림. yield return(new WaitForSeconds(preDelay)); #endregion if (isReallyFire) { #region 투사체 발사 // 20 02 09 체력이 0 이상이고, CC기 맞은 상태가 아닐 경우 투사체 발사. // cc기 피격 또는 사망시 코루틴을 아예 중지해 버리면 쿨타임 계산을 다시 해주어야 하므로 투사체만 발사하지 않는것으로 작성. // 상기 상황시 Character.cs 에서 character state 바뀌고, character state에 따라 EffectController.cs에서 사망/CC 애니메이션 재생함 if (caster.GetState != Robot.State.Die && caster.GetState != Robot.State.CC) { // 스킬 발사 상태 변경 2020 01 30 state = State.Fire; ProjectileInfo info = ProjectileInfo(caster, dir); Vector3 spawnPos = caster.transform.position + new Vector3(0, 1.1f, 0); Projectile projectile = UnityEngine.Object.Instantiate(proj, spawnPos, Quaternion.identity); projectile.Initialize(info); } #endregion } caster.ShowMuzzleEffect(true); SoundManager.instance.PlaySound("RobotAttack", 0.1f); #region Wait for Post Delay yield return(new WaitForSeconds(postDelay)); caster.ShowMuzzleEffect(false); #endregion state = State.CoolDown; #region Cool Down... remainCool = coolDown; while (remainCool > 0) { remainCool -= Time.fixedDeltaTime; yield return(new WaitForFixedUpdate()); } remainCool = 0; #endregion state = State.Idle; }
public void EmitProjectile(ProjectileInfo projectileInfo) { MechaComponent mc = ClientBattleManager.Instance.FindMechaComponent(projectileInfo.ParentExecuteInfo.MechaComponentInfo.GUID); if (mc != null && !mc.MechaInfo.IsDead) { Transform dummyPos = mc.DummyPosDict[projectileInfo.ProjectileConfig.DummyPos]; ShootProjectile(projectileInfo, dummyPos.position, dummyPos.forward, dummyPos); } }
private Projectile ShootProjectile(ProjectileInfo projectileInfo, Vector3 from, Vector3 dir, Transform dummyPos) { Projectile projectile = GameObjectPoolManager.Instance.ProjectileDict[projectileInfo.ProjectileType].AllocateGameObject <Projectile>(Root); projectile.transform.position = from; projectile.transform.LookAt(from + dir); projectile.Initialize(projectileInfo); projectile.Launch(dummyPos); return(projectile); }
public override void Execute(GameObject go, ProjectileInfo proj, PointInfo info) { var health = go.GetComponent <PlayerHealth>(); if (health == null) { return; } health.SetDamage(this.damage, proj.weapon.owner); }
public void SetProjectileInfo(ProjectileInfo info, string owner, float scale) { transform.localScale = new Vector3(scale, transform.localScale.y, transform.localScale.z); this.owner = owner; this.tag = owner; pInfo = info; pInfo.velocity.x = Mathf.Abs(pInfo.velocity.x) * scale; gameObject.SetActive(true); }
public virtual ProjectileInfo Clone() { ProjectileInfo info = new ProjectileInfo(); info.CollisionLayer = CollisionLayer; info.InitialSpeed = InitialSpeed; info.ProjectileType = ProjectileType; info.Damage = Damage; return(info); }
//private List<GameObject> AllProjectiles = new List<GameObject>(); public Projectile ShootProjectile(ProjectileInfo projectileInfo, Vector3 from, Vector3 dir) { Projectile projectile = GameObjectPoolManager.Instance.ProjectileDict[projectileInfo.ProjectileType].AllocateGameObject <Projectile>(transform); projectile.transform.position = from; projectile.transform.LookAt(from + dir); projectile.Initialize(projectileInfo); StartCoroutine(Co_ShootProjectile(projectile)); return(projectile); }
public void OnInitialize(ProjectileInfo _info, Vector2 direction) { var info = _info as GrenadeBulletInfo; _bounceVelocityMultiplier = info.OnHitVeclocityMultiplier; _hopUp = info.HopUpFactor; _explosionInfo = info.ExplosionInfo; Fire(direction.normalized * info.InitialSpeed); ExpireCheckCoroutineHandler = StartCoroutine(ExpireCheckCorutine()); }
private ProjectileInfo ProjectileInfo(Robot caster, Vector3 dir) { List <SkillEffect> effects = new List <SkillEffect>(); effect.amount = -(int)caster.GetStatus.ATK; effects.Add(effect); ProjectileInfo info = new ProjectileInfo(caster.CampNum, dir, speed, range, size, 0, TargetType.Enemy, TargetNum.One, effects); return(info); }
public BaseInfo() { attackEffectInfo = new ActionEffectInfo(); animationInfo = new AnimationInfo(); audioInfo = new AudioInfo(); attackModifierIcons = new List<string>(); projectileInfo = null; }