public void UserInformation(S.UserInformation p) { User.gameObject.SetActive(true); UserGameObject = Instantiate(WarriorModels[0], User.transform.position, Quaternion.identity); User.Player = UserGameObject.GetComponent <PlayerObject>(); User.Player.name = p.Name; User.Player.Class = p.Class; User.Player.Gender = p.Gender; User.Level = p.Level; GameScene.UpdateCharacterIcon(); User.Player.CurrentLocation = new Vector2(p.Location.X, p.Location.Y); UserGameObject.transform.position = CurrentScene.Cells[(int)User.Player.CurrentLocation.x, (int)User.Player.CurrentLocation.y].position; User.Player.Direction = p.Direction; User.Player.Model.transform.rotation = ClientFunctions.GetRotation(User.Player.Direction); User.Inventory = p.Inventory; User.Equipment = p.Equipment; User.BindAllItems(); Players.Add(p.ObjectID, User.Player); User.Player.Camera.SetActive(true); Tooltip.cam = User.Player.Camera.GetComponent <Camera>(); }
public void ObjectPlayer(S.ObjectPlayer p) { MapObject ob; PlayerObject player; if (ObjectList.TryGetValue(p.ObjectID, out ob)) { player = (PlayerObject)ob; player.CurrentLocation = new Vector2(p.Location.X, p.Location.Y); player.Direction = p.Direction; player.transform.position = CurrentScene.Cells[p.Location.X, p.Location.Y].position; player.Model.transform.rotation = ClientFunctions.GetRotation(p.Direction); player.Armour = p.Armour; player.Weapon = p.Weapon; player.gameObject.SetActive(true); CurrentScene.Cells[p.Location.X, p.Location.Y].AddObject(player); return; } player = Instantiate(PlayerModel, CurrentScene.Cells[p.Location.X, p.Location.Y].position, Quaternion.identity).GetComponent <PlayerObject>(); player.gameManager = this; player.Name = p.Name; player.ObjectID = p.ObjectID; player.CurrentLocation = new Vector2(p.Location.X, p.Location.Y); player.Direction = p.Direction; player.Model.transform.rotation = ClientFunctions.GetRotation(p.Direction); player.Armour = p.Armour; player.Weapon = p.Weapon; ObjectList.Add(p.ObjectID, player); CurrentScene.Cells[p.Location.X, p.Location.Y].AddObject(player); }
public void ObjectNPC(S.ObjectNPC p) { MapObject ob; NPCObject npc; if (ObjectList.TryGetValue(p.ObjectID, out ob)) { npc = (NPCObject)ob; npc.Name = p.Name; npc.CurrentLocation = new Vector2(p.Location.X, p.Location.Y); npc.Direction = p.Direction; npc.transform.position = CurrentScene.Cells[p.Location.X, p.Location.Y].position; npc.Model.transform.rotation = ClientFunctions.GetRotation(p.Direction); npc.gameObject.SetActive(true); CurrentScene.Cells[p.Location.X, p.Location.Y].AddObject(npc); return; } if (p.Image >= NPCModels.Count) { npc = Instantiate(NPCModels[0], CurrentScene.Cells[p.Location.X, p.Location.Y].position, Quaternion.identity).GetComponent <NPCObject>(); } else { npc = Instantiate(NPCModels[p.Image], CurrentScene.Cells[p.Location.X, p.Location.Y].position, Quaternion.identity).GetComponent <NPCObject>(); } npc.Name = p.Name; npc.ObjectID = p.ObjectID; npc.CurrentLocation = new Vector2(p.Location.X, p.Location.Y); npc.Direction = p.Direction; npc.Model.transform.rotation = ClientFunctions.GetRotation(p.Direction); CurrentScene.Cells[p.Location.X, p.Location.Y].AddObject(npc); ObjectList.Add(p.ObjectID, npc); }
public void ObjectMonster(S.ObjectMonster p) { MapObject ob; MonsterObject monster; if (ObjectList.TryGetValue(p.ObjectID, out ob)) { monster = (MonsterObject)ob; monster.Name = p.Name; monster.CurrentLocation = new Vector2(p.Location.X, p.Location.Y); monster.Direction = p.Direction; monster.transform.position = CurrentScene.Cells[p.Location.X, p.Location.Y].position; monster.Model.transform.rotation = ClientFunctions.GetRotation(p.Direction); monster.gameObject.SetActive(true); if (p.Dead) { monster.Dead = true; monster.CurrentAction = MirAction.Dead; } else { CurrentScene.Cells[p.Location.X, p.Location.Y].AddObject(monster); } return; } if ((int)p.Image >= MonsterModels.Count) { monster = Instantiate(MonsterModels[0], CurrentScene.Cells[p.Location.X, p.Location.Y].position, Quaternion.identity).GetComponent <MonsterObject>(); } else { monster = Instantiate(MonsterModels[(int)p.Image], CurrentScene.Cells[p.Location.X, p.Location.Y].position, Quaternion.identity).GetComponent <MonsterObject>(); } monster.Name = p.Name; monster.ObjectID = p.ObjectID; monster.Scale = p.Scale; monster.CurrentLocation = new Vector2(p.Location.X, p.Location.Y); monster.Direction = p.Direction; monster.Model.transform.rotation = ClientFunctions.GetRotation(p.Direction); if (p.Dead) { monster.Dead = true; monster.CurrentAction = MirAction.Dead; } else { CurrentScene.Cells[p.Location.X, p.Location.Y].AddObject(monster); } ObjectList.Add(p.ObjectID, monster); }
public override void SetAction() { if (ActionFeed.Count == 0) { if (Dead) { CurrentAction = MirAction.Dead; } else { CurrentAction = MirAction.Standing; } } else { QueuedAction action = ActionFeed[0]; ActionFeed.RemoveAt(0); CurrentAction = action.Action; Direction = action.Direction; Model.transform.rotation = ClientFunctions.GetRotation(Direction); switch (CurrentAction) { case MirAction.Walking: case MirAction.Running: int steps = 1; if (CurrentAction == MirAction.Running) { steps = 2; } Vector3 targetpos = GameManager.CurrentScene.Cells[(int)action.Location.x, (int)action.Location.y].position; TargetPosition = targetpos; Vector2 back = ClientFunctions.Back(action.Location, Direction, steps); gameObject.transform.position = GameManager.CurrentScene.Cells[(int)back.x, (int)back.y].position; GameManager.CurrentScene.Cells[CurrentLocation.x, CurrentLocation.y].RemoveObject(this); GameManager.CurrentScene.Cells[action.Location.x, action.Location.y].AddObject(this); StartPosition = gameObject.transform.position; TargetDistance = Vector3.Distance(transform.position, targetpos); IsMoving = true; break; } CurrentLocation = action.Location; } GetComponentInChildren <Animator>().SetInteger("CurrentAction", (int)CurrentAction); }
public void UserInformation(S.UserInformation p) { User.gameObject.SetActive(true); UserGameObject = Instantiate(PlayerModel, User.transform.position, Quaternion.identity); UserGameObject.GetComponent <BoxCollider>().enabled = true; User.Player = UserGameObject.GetComponent <PlayerObject>(); User.Player.gameManager = this; User.Player.ObjectID = p.ObjectID; User.SetName(p.Name); User.SetClass(p.Class); User.Player.Gender = p.Gender; User.Player.SetModel(); User.SetLevel(p.Level); User.Experience = p.Experience; User.MaxExperience = p.MaxExperience; User.HP = p.HP; User.MP = p.MP; User.Player.HealthTime = float.MaxValue; User.Gold = p.Gold; User.Credit = p.Credit; GameScene.UpdateCharacterIcon(); User.Player.CurrentLocation = new Vector2Int(p.Location.X, p.Location.Y); UserGameObject.transform.position = CurrentScene.Cells[User.Player.CurrentLocation.x, User.Player.CurrentLocation.y].position; User.Player.Direction = p.Direction; User.Player.Model.transform.rotation = ClientFunctions.GetRotation(User.Player.Direction); User.Inventory = p.Inventory; User.Equipment = p.Equipment; User.Magics = p.Magics; foreach (ClientMagic magic in User.Magics) { GameScene.SkillDialog.AddMagic(magic); } User.BindAllItems(); User.Player.Camera.SetActive(true); //User.Player.MiniMapCamera.SetActive(true); ObjectList.Add(p.ObjectID, User.Player); UserGameObject.GetComponentInChildren <AudioListener>().enabled = true; Tooltip.cam = User.Player.Camera.GetComponent <Camera>(); GameScene.partyController.name = User.Player.Name; }
public void ObjectMonster(S.ObjectMonster p) { MapObject ob; MonsterObject monster; if (ObjectList.TryGetValue(p.ObjectID, out ob)) { monster = (MonsterObject)ob; monster.Name = p.Name; monster.NameColour = ConvertSystemColor(p.NameColour); monster.CurrentLocation = new Vector2Int(p.Location.X, p.Location.Y); monster.Direction = p.Direction; monster.transform.position = CurrentScene.Cells[p.Location.X, p.Location.Y].position; monster.Model.transform.rotation = ClientFunctions.GetRotation(p.Direction); monster.gameObject.SetActive(true); monster.Dead = p.Dead; monster.Blocking = !p.Dead; monster.Class = p.MobClass; return; } if ((int)p.Image >= MonsterModels.Count) { monster = Instantiate(MonsterModels[0], CurrentScene.Cells[p.Location.X, p.Location.Y].position, Quaternion.identity).GetComponent <MonsterObject>(); } else { monster = Instantiate(MonsterModels[(int)p.Image], CurrentScene.Cells[p.Location.X, p.Location.Y].position, Quaternion.identity).GetComponent <MonsterObject>(); } monster.Name = p.Name; monster.NameColour = ConvertSystemColor(p.NameColour); monster.ObjectID = p.ObjectID; monster.Scale = p.Scale; monster.CurrentLocation = new Vector2Int(p.Location.X, p.Location.Y); monster.Direction = p.Direction; monster.Model.transform.rotation = ClientFunctions.GetRotation(p.Direction); monster.OutlineMaterial = OutlineMaterial; monster.Dead = p.Dead; monster.Blocking = !p.Dead; monster.Class = p.MobClass; CurrentScene.Cells[p.Location.X, p.Location.Y].AddObject(monster); ObjectList.Add(p.ObjectID, monster); monster.BossUI(monster); }
public void ObjectPlayer(S.ObjectPlayer p) { PlayerObject player; if (Players.TryGetValue(p.ObjectID, out player)) { player.CurrentLocation = new Vector2(p.Location.X, p.Location.Y); player.Direction = p.Direction; player.transform.position = CurrentScene.Cells[p.Location.X, p.Location.Y].position; player.Model.transform.rotation = ClientFunctions.GetRotation(p.Direction); player.gameObject.SetActive(true); return; } player = Instantiate(WarriorModels[0], CurrentScene.Cells[p.Location.X, p.Location.Y].position, Quaternion.identity).GetComponent <PlayerObject>(); player.CurrentLocation = new Vector2(p.Location.X, p.Location.Y); player.Direction = p.Direction; player.Model.transform.rotation = ClientFunctions.GetRotation(p.Direction); Players.Add(p.ObjectID, player); }
public void UserInformation(S.UserInformation p) { User.gameObject.SetActive(true); UserGameObject = Instantiate(PlayerModel, User.transform.position, Quaternion.identity); UserGameObject.GetComponentInChildren <AudioListener>().enabled = true; User.Player = UserGameObject.GetComponent <PlayerObject>(); User.Player.ObjectID = p.ObjectID; User.Player.ObjectID = p.ObjectID; User.SetName(p.Name); User.SetClass(p.Class); User.Player.Gender = p.Gender; User.SetLevel(p.Level); User.Experience = p.Experience; User.MaxExperience = p.MaxExperience; User.HP = p.HP; User.MP = p.MP; GameScene.UpdateCharacterIcon(); User.Player.CurrentLocation = new Vector2(p.Location.X, p.Location.Y); User.Player.gameManager = this; UserGameObject.transform.position = CurrentScene.Cells[(int)User.Player.CurrentLocation.x, (int)User.Player.CurrentLocation.y].position; User.Player.Direction = p.Direction; User.Player.Model.transform.rotation = ClientFunctions.GetRotation(User.Player.Direction); User.Inventory = p.Inventory; User.Equipment = p.Equipment; User.Magics = p.Magics; User.BindAllItems(); User.Player.Camera.SetActive(true); User.Player.MiniMapCamera.SetActive(true); Tooltip.cam = User.Player.Camera.GetComponent <Camera>(); }
public override void SetAction() { if (this == GameManager.User.Player && Time.time > GameManager.NextAction && GameScene.QueuedAction != null) { ActionFeed.Clear(); ActionFeed.Add(GameScene.QueuedAction); GameScene.QueuedAction = null; } if (ActionFeed.Count == 0) { if (Dead) { CurrentAction = MirAction.Dead; } else { CurrentAction = MirAction.Standing; } } else { if (this == GameManager.User.Player && Time.time < GameManager.NextAction) { return; } QueuedAction action = ActionFeed[0]; ActionFeed.RemoveAt(0); CurrentAction = action.Action; Direction = action.Direction; Model.transform.rotation = ClientFunctions.GetRotation(Direction); switch (CurrentAction) { case MirAction.Walking: case MirAction.Running: int steps = 1; if (CurrentAction == MirAction.Running) { steps = 2; } Vector3 targetpos = GameManager.CurrentScene.Cells[action.Location.x, action.Location.y].position; TargetPosition = targetpos; if (this != GameManager.User.Player) { Vector2Int back = ClientFunctions.Back(action.Location, Direction, steps); gameObject.transform.position = GameManager.CurrentScene.Cells[back.x, back.y].position; } GameManager.CurrentScene.Cells[CurrentLocation.x, CurrentLocation.y].RemoveObject(this); GameManager.CurrentScene.Cells[action.Location.x, action.Location.y].AddObject(this); StartPosition = gameObject.transform.position; TargetDistance = Vector3.Distance(transform.position, targetpos); IsMoving = true; RefreshSounds(); break; } CurrentLocation = action.Location; Spell = Spell.None; if (this == GameManager.User.Player) { switch (CurrentAction) { case MirAction.Standing: Network.Enqueue(new C.Turn { Direction = action.Direction }); GameManager.NextAction = Time.time + 2.5f; GameManager.InputDelay = Time.time + 0.5f; GameManager.User.CanRun = false; break; case MirAction.Walking: Network.Enqueue(new C.Walk { Direction = action.Direction }); GameManager.NextAction = Time.time + 2.5f; GameManager.InputDelay = Time.time + 0.5f; GameManager.User.LastRunTime = Time.time; GameManager.User.CanRun = true; break; case MirAction.Running: Network.Enqueue(new C.Run { Direction = action.Direction }); GameManager.NextAction = Time.time + 2.5f; GameManager.InputDelay = Time.time + 0.5f; GameManager.User.LastRunTime = Time.time; break; case MirAction.Attack: if (GameScene.Slaying && GameScene.TargetObject != null) { Spell = Spell.Slaying; GameScene.Slaying = false; } Network.Enqueue(new C.Attack { Direction = Direction, Spell = Spell }); GameManager.NextAction = Time.time + 2.5f; break; case MirAction.Die: Blocking = false; if (HealthBar != null) { HealthBar.gameObject.SetActive(false); } break; case MirAction.Revive: Blocking = true; ActionFeed.Clear(); ActionFeed.Add(new QueuedAction { Action = MirAction.Standing, Direction = action.Direction }); //GameScene.pControl.TextureValid = false; break; } } switch (CurrentAction) { case MirAction.Attack: PlayAnimation("Attack", -1, 0); break; case MirAction.Struck: SetAnimation("Struck", true); break; } } //GetComponentInChildren<Animator>()?.SetInteger("CurrentAction", (int)CurrentAction); SetAnimation("CurrentAction", (int)CurrentAction); }
void SetAction() { if (ActionFeed.Count == 0) { CurrentAction = MirAction.Standing; if (this == GameManager.User.Player) { GameManager.User.WalkStep = 0; } } else { if (Time.time < GameManager.NextAction) { return; } QueuedAction action = ActionFeed[0]; ActionFeed.RemoveAt(0); CurrentAction = action.Action; Direction = action.Direction; switch (CurrentAction) { case MirAction.Walking: case MirAction.Running: int steps = 1; if (CurrentAction == MirAction.Running) { steps = 2; } Vector3 targetpos = GameManager.CurrentScene.Cells[(int)action.Location.x, (int)action.Location.y].position; Model.transform.rotation = ClientFunctions.GetRotation(Direction); TargetPosition = targetpos; if (this != GameManager.User.Player) { Vector2 back = ClientFunctions.Back(action.Location, Direction, steps); gameObject.transform.position = GameManager.CurrentScene.Cells[(int)back.x, (int)back.y].position; } StartPosition = gameObject.transform.position; TargetDistance = Vector3.Distance(transform.position, targetpos); IsMoving = true; break; } CurrentLocation = action.Location; if (this == GameManager.User.Player) { switch (CurrentAction) { case MirAction.Walking: Network.Enqueue(new C.Walk { Direction = action.Direction }); GameManager.NextAction = Time.time + 2.5f; GameManager.InputDelay = Time.time + 0.5f; break; case MirAction.Running: Network.Enqueue(new C.Run { Direction = action.Direction }); GameManager.NextAction = Time.time + 2.5f; GameManager.InputDelay = Time.time + 0.5f; break; } } } GetComponentInChildren <Animator>().SetInteger("CurrentAction", (int)CurrentAction); }
public override void SetAction() { if (this == GameManager.User.Player && GameScene.QueuedAction != null) { ActionFeed.Clear(); ActionFeed.Add(GameScene.QueuedAction); GameScene.QueuedAction = null; } if (ActionFeed.Count == 0) { CurrentAction = MirAction.Standing; } else { if (this == GameManager.User.Player && Time.time < GameManager.NextAction) { return; } QueuedAction action = ActionFeed[0]; ActionFeed.RemoveAt(0); CurrentAction = action.Action; Direction = action.Direction; Model.transform.rotation = ClientFunctions.GetRotation(Direction); switch (CurrentAction) { case MirAction.Walking: case MirAction.Running: int steps = 1; if (CurrentAction == MirAction.Running) { steps = 2; } Vector3 targetpos = GameManager.CurrentScene.Cells[(int)action.Location.x, (int)action.Location.y].position; TargetPosition = targetpos; if (this != GameManager.User.Player) { Vector2 back = ClientFunctions.Back(action.Location, Direction, steps); gameObject.transform.position = GameManager.CurrentScene.Cells[(int)back.x, (int)back.y].position; } GameManager.CurrentScene.Cells[(int)CurrentLocation.x, (int)CurrentLocation.y].RemoveObject(this); GameManager.CurrentScene.Cells[(int)action.Location.x, (int)action.Location.y].AddObject(this); StartPosition = gameObject.transform.position; TargetDistance = Vector3.Distance(transform.position, targetpos); IsMoving = true; break; } CurrentLocation = action.Location; if (this == GameManager.User.Player) { switch (CurrentAction) { case MirAction.Standing: Network.Enqueue(new C.Turn { Direction = action.Direction }); GameManager.NextAction = Time.time + 2.5f; GameManager.InputDelay = Time.time + 0.5f; GameManager.User.CanRun = false; break; case MirAction.Walking: Network.Enqueue(new C.Walk { Direction = action.Direction }); GameManager.NextAction = Time.time + 2.5f; GameManager.InputDelay = Time.time + 0.5f; GameManager.User.LastRunTime = Time.time; GameManager.User.CanRun = true; break; case MirAction.Running: Network.Enqueue(new C.Run { Direction = action.Direction }); GameManager.NextAction = Time.time + 2.5f; GameManager.InputDelay = Time.time + 0.5f; GameManager.User.LastRunTime = Time.time; break; case MirAction.Attack: Network.Enqueue(new C.Attack { Direction = Direction, Spell = Spell.None }); GameManager.NextAction = Time.time + 2.5f; break; } } switch (CurrentAction) { case MirAction.Attack: GetComponentInChildren <Animator>().Play("Attack", -1, normalizedTime: 0f); break; } } GetComponentInChildren <Animator>()?.SetInteger("CurrentAction", (int)CurrentAction); }
public override void SetAction() { if (ActionFeed.Count == 0) { if (Dead) { CurrentAction = MirAction.Dead; } else { CurrentAction = MirAction.Standing; } } else { QueuedAction action = ActionFeed[0]; ActionFeed.RemoveAt(0); CurrentAction = action.Action; Direction = action.Direction; Model.transform.rotation = ClientFunctions.GetRotation(Direction); BossHealupdate(); switch (CurrentAction) { case MirAction.Walking: case MirAction.Running: int steps = 1; if (CurrentAction == MirAction.Running) { steps = 2; } Vector3 targetpos = GameManager.CurrentScene.Cells[(int)action.Location.x, (int)action.Location.y].position; TargetPosition = targetpos; Vector2 back = ClientFunctions.Back(action.Location, Direction, steps); gameObject.transform.position = GameManager.CurrentScene.Cells[(int)back.x, (int)back.y].position; GameManager.CurrentScene.Cells[CurrentLocation.x, CurrentLocation.y].RemoveObject(this); GameManager.CurrentScene.Cells[action.Location.x, action.Location.y].AddObject(this); StartPosition = gameObject.transform.position; TargetDistance = Vector3.Distance(transform.position, targetpos); IsMoving = true; break; case MirAction.Attack: soundPlayer.ExecuteSound(AttackSound, gameObject, "Player"); soundPlayer.Play(); break; case MirAction.Struck: break; case MirAction.Die: soundPlayer.ExecuteSound(DeathSound, gameObject, "Player"); soundPlayer.Play(); Blocking = false; if (HealthBar != null) { HealthBar.gameObject.SetActive(false); } CheckBossDead(); Dead = true; break; } CurrentLocation = action.Location; } GetComponentInChildren <Animator>().SetInteger("CurrentAction", (int)CurrentAction); }