public void Attack(Vector3 dir) { // Attack Vector3 boltShootDir = (GetMouseWorldPosition() - transform.position).normalized; float boltOffset = 10f; Vector3 boltSpawnPosition = transform.position + boltShootDir * boltOffset; ProjectileBolt.Create(boltSpawnPosition, boltShootDir); SetStateAttacking(); Vector3 attackDir = boltShootDir; Transform swordSlashTransform = Instantiate(GameAssets.i.pfSwordSlash, GetPosition() + attackDir * 13f, Quaternion.Euler(0, 0, GetAngleFromVector(attackDir))); swordSlashTransform.GetComponent <SpriteAnimator>().onLoop = () => Destroy(swordSlashTransform.gameObject); UnitAnimType activeAnimType = characterBase.GetUnitAnimation().GetActiveAnimType(); if (activeAnimType == GameAssets.UnitAnimTypeEnum.dSwordTwoHandedBack_Sword) { swordSlashTransform.localScale = new Vector3(swordSlashTransform.localScale.x, swordSlashTransform.localScale.y * -1, swordSlashTransform.localScale.z); characterBase.GetUnitAnimation().PlayAnimForced(GameAssets.UnitAnimTypeEnum.dSwordTwoHandedBack_Sword2, attackDir, 1f, (UnitAnim unitAnim) => SetStateNormal(), null, null); } else { characterBase.GetUnitAnimation().PlayAnimForced(GameAssets.UnitAnimTypeEnum.dSwordTwoHandedBack_Sword, attackDir, 1f, (UnitAnim unitAnim) => SetStateNormal(), null, null); } }
public static void Create(Vector3 spawnPosition, Vector3 moveDir) { Transform boltTransform = Instantiate(GameAssets.i.pfBolt, spawnPosition, Quaternion.identity); ProjectileBolt projectileBolt = boltTransform.GetComponent <ProjectileBolt>(); projectileBolt.Setup(moveDir); }
public override void Launch(GameObject actor, int posX, int posY, FInt velX, FInt velY) { // Green Bolts have random direction casting: Random rand = new Random((int)Systems.timer.Frame); FInt modY = FInt.Create(rand.Next(-20, 20) * 0.1); var projectile = ProjectileBolt.Create(actor.room, (byte)ProjectileBoltSubType.Green, FVector.Create(posX, posY), FVector.Create(velX, velY + modY)); projectile.SetActorID(actor); }
///<summary> ///add a bolt to the game ///</summary> ///<param name="shooter"></param> ///<param name="target"></param> public void AddBolt(BotEntity shooter, Vector2 target) { Projectile projectile = new ProjectileBolt(shooter, target, new BoltSceneObject()); Projectiles.Add(projectile); projectile.Name = "TempBoltName"; //register the bolt with the entity manager EntityManager.Instance.RegisterEntity(projectile); projectile.Name = "BOLT_" + projectile.ObjectId; LogUtil.WriteLineIfLogCreate("Adding a bolt " + projectile.ObjectId + " at position " + projectile.Position); }
public override void Launch(GameObject actor, int posX, int posY, FInt velX, FInt velY) { var projectile = ProjectileBolt.Create(actor.room, (byte)ProjectileBoltSubType.Gold, FVector.Create(posX, posY), FVector.Create(velX, velY)); projectile.SetActorID(actor); }