/// <summary> /// Sends object to the given position. /// </summary> /// <param name="imgo">The moving game object.</param> /// <param name="to">The point of the moving.</param> public void GoToLocation(IMovableGameObject imgo, Mogre.Vector3 to) { var a = new LinkedList <Mogre.Vector3>(); a.AddLast(to); imgo.SetNextLocation(a); }
/// <summary> /// Checks if the adding group is an atacker or a deffender and inserts it to /// the appropriate group and recalculates it. /// </summary> /// <param name="group">The inserting group.</param> public void AddGroup(GroupMovables group) { GroupManager groupMgr = Game.GroupManager; if (group.Team == groupAttackers.Team) { // Group is attacker int groupCount = group.Count; for (int i = 0; i < groupCount; i++) { IMovableGameObject temp = group[0]; groupMgr.RemoveFromGroup(temp); groupMgr.AddToGroup(groupAttackers, temp); temp.StartAttack(this); } groupAttackers.Reselect(); groupMgr.SelectGroup(groupAttackers); } else { // Group is deffender int groupCount = group.Count; for (int i = 0; i < groupCount; i++) { IMovableGameObject temp = group[0]; groupMgr.RemoveFromGroup(temp); groupMgr.AddToGroup(imgoDeffenders, temp); temp.StartAttack(this); } groupAttackers.Reselect(); groupMgr.SelectGroup(imgoDeffenders); } }
/// <summary> /// Removes the IMovableGameObject from the SolarSystem. /// </summary> /// <param name="imgo">The removing object.</param> public void RemoveIMGO(IMovableGameObject imgo) { if (imgoObjectDict.ContainsKey(imgo.Name)) { imgoObjectDict.Remove(imgo.Name); } }
/// <summary> /// Shows GUI panel with possible travel destiantions and playes portal animation. /// </summary> /// <param name="imgo"></param> public void ShowTravelDestinations(IMovableGameObject imgo) { Game.CreateInterstellarTravel(imgo); isPorting = true; portTimeDuration = portTime; }
/// <summary> /// Removes the given movable object from the dictionary which contains controled movements. /// </summary> /// <param name="imgo"></param> public void UnlogFromFinishMoveReciever(IMovableGameObject imgo) { if (finishMoveRecDict.ContainsKey(imgo)) { finishMoveRecDict.Remove(imgo); } }
/// <summary> /// Inserts the given movable object to the team and sets its the team. /// </summary> /// <param name="imgo">The inserting movable object.</param> public void AddIMGO(IMovableGameObject imgo) { if (!imgoObjects.Contains(imgo)) { imgoObjects.Add(imgo); imgo.Team = this; } }
/// <summary> /// Recieves information when object reached the destination. Checks if object is attacking or occupying and /// creates the appropriate class. /// </summary> /// <param name="imgo">The object in destiantion.</param> public void MovementFinished(IMovableGameObject imgo) { var onWayCopy = new Dictionary <IMovableGameObject, GroupMovables>(onWayToTargetDict); var group = onWayCopy[imgo]; var gameObject = attackersTarget[imgo]; var moveMgr = Game.IMoveManager; // Remove all object which goint to the same target from a watch lists. foreach (IMovableGameObject item in onWayCopy[imgo]) { onWayToTargetDict.Remove(item); attackersTarget.Remove(item); moveMgr.UnlogFromFinishMoveReciever(item); } if (offensiveActionDict[onWayCopy[imgo]] == ActionAnswer.Attack) { // Creates a Fight fightList.Add(new Fight(group, gameObject)); } else { // Creates an Occupation occupationList.Add(new Occupation(group, gameObject)); } offensiveActionDict.Remove(onWayCopy[imgo]); }
/// <summary> /// Removes the given movable object from the team. /// </summary> /// <param name="imgo">The removing movable object.</param> public void RemoveIMGO(IMovableGameObject imgo) { if (imgoObjects.Contains(imgo)) { imgoObjects.Remove(imgo); } }
/// <summary> /// Removes given object from attackes targets. If the removing object is the current /// target then selects a new one. /// </summary> /// <param name="igo">The removing target.</param> private void RemoveFromAttackerTarget(IMovableGameObject igo) { imgoDeffenders.RemoveMember(igo); if (attackerTarget.Value == igo) { SelectAttackerTarget(); } }
/// <summary> /// Inserts the IMovableGameObject to the SolarSystem and sets SolarSystem visibility /// to the object. /// </summary> /// <param name="imgo">The inserting object.</param> public void AddIMGO(IMovableGameObject imgo) { if (!imgoObjectDict.ContainsKey(imgo.Name)) { imgoObjectDict.Add(imgo.Name, imgo); imgo.ChangeVisible(active); } }
/// <summary> /// Creates IMovableGameObject by given typeName and argument. Inserts the object to given SolarSystem and registers it in HitTest. /// </summary> /// <param name="typeName">The type of the creating object.</param> /// <param name="args">The arguments of the creating object.</param> /// <param name="solSyst">The creating object SolarSystem.</param> /// <returns>Returns created IMovableGameObject.</returns> public IMovableGameObject CreateImgo(string typeName, object[] args, SolarSystem solSyst) // prepared...never used { IMovableGameObject imgo = xmlLoader.CreateIMGO(typeName, args); solSyst.AddIMGO(imgo); Game.HitTest.RegisterIMGO(imgo); return(imgo); }
/// <summary> /// Attempts to remove IMovableGameObject from its group. /// </summary> /// <param Name="imgo">IMovableGameObject to remove from the group</param> public void RemoveFromGroup(IMovableGameObject imgo) { if (imgoGroupDict.ContainsKey(imgo)) { imgoGroupDict[imgo].RemoveMember(imgo); imgoGroupDict.Remove(imgo); } }
/// <summary> /// Unlogs given object from a watch lists. /// </summary> /// <param name="imgo">The object which interrupted the movement.</param> public void MovementInterupted(IMovableGameObject imgo) { if (onWayToTargetDict.ContainsKey(imgo)) { offensiveActionDict.Remove(onWayToTargetDict[imgo]); onWayToTargetDict.Remove(imgo); attackersTarget.Remove(imgo); } }
/// <summary> /// Removes the object from controlled movements and if something controls the movement /// so it sends the information to it. /// </summary> /// <param name="imgo">The object which interupted the movement.</param> public void MovementInterupted(IMovableGameObject imgo) { moveMgrControledDict.Remove(imgo); if (finishMoveRecDict.ContainsKey(imgo)) { finishMoveRecDict[imgo].MovementInterupted(imgo); finishMoveRecDict.Remove(imgo); } }
/// <summary> /// Finds IMovableGameObject at SolarSystems and removes it from the one. /// </summary> /// <param name="imgo">The removing object.</param> public void RemoveObjectFromSolarSystem(IMovableGameObject imgo) { foreach (var solSysPair in solarSystemDict) { if (solSysPair.Value.HasIMGO(imgo)) { solSysPair.Value.RemoveIMGO(imgo); break; } } }
/// <summary> /// Creates traveler from its current SolarSystem to new given SolarSystem. /// Object is removed and insert to new one by Traveler class. /// Also playes travel sound. /// </summary> /// <param name="from">The current object SolarSystem.</param> /// <param name="to">The future object SolarSystem.</param> /// <param name="gameObject">The traveling game object.</param> public static void CreateTraveler(SolarSystem from, SolarSystem to, object gameObject) { if (gameObject is IMovableGameObject) { if (from != to) { IMovableGameObject imgo = (IMovableGameObject)gameObject; Game.IEffectPlayer.PlayEffect(travelSound); travelerList.Add(new Traveler(from, to, (IMovableGameObject)imgo)); } } }
/// <summary> /// Recives the information that the constolled object reached the destination. /// Reports the information if some class wants to control this movement and /// sends the information to object to which the imgo travels. /// </summary> /// <param Name="imgo">The object which reached the destination.</param> /// <param Name="isgo">The target of the movement.</param> private void ReachedDestiantion(IMovableGameObject imgo, IGameObject gameObject) { if (finishMoveRecDict.ContainsKey(imgo)) { finishMoveRecDict[imgo].MovementFinished(imgo); finishMoveRecDict.Remove(imgo); } if (imgo.Visible) { imgo.Stop(); gameObject.TargetInSight(imgo); } }
/// <summary> /// Removes given object from deffenders targets. If the removing object is the current /// target then selects a new one. Also controls if exist any next attacker (if not fight ends). /// </summary> /// <param name="igo">The removing target.</param> private void RemoveFromDeffenderTarget(IMovableGameObject igo) { groupAttackers.RemoveMember(igo); if (deffenderTarget.Value == igo) { if (groupAttackers.Count != 0) { deffenderTarget.Value = groupAttackers[0]; } else { EndFight(); } } }
/// <summary> /// Initializes Traveler and calculates the time of the travel (from the distance between /// SolarSystems). Also creates the object invisible and removes it from current SolarSystem. /// </summary> /// <param name="from">The SolarSystem with the traveler</param> /// <param name="to">The target SolarSystem of the traveler</param> /// <param name="traveler">The traveling object</param> public Traveler(SolarSystem from, SolarSystem to, IMovableGameObject traveler) { this.from = from; this.to = to; this.traveler = traveler; long travelTime = (long)GetSquareOfDistance(from, to); timeToGo = new Property<TimeSpan>(new TimeSpan(travelTime*60)); // Multiply by 60 traveler.Stop(); // Removes from current SolarSystem from.RemoveIMGO(traveler); traveler.ChangeVisible(false); }
/// <summary> /// Initializes Traveler and calculates the time of the travel (from the distance between /// SolarSystems). Also creates the object invisible and removes it from current SolarSystem. /// </summary> /// <param name="from"></param> /// <param name="to"></param> /// <param name="traveler"></param> public Traveler(SolarSystem from, SolarSystem to, IMovableGameObject traveler) { this.from = from; this.to = to; this.traveler = traveler; long travelTime = (long)GetSquareOfDistance(from, to); timeToGo = new Property <TimeSpan>(new TimeSpan(travelTime * 60)); // Multiply by 60 traveler.Stop(); // Removes from current SolarSystem from.RemoveIMGO(traveler); traveler.ChangeVisible(false); }
/// <summary> /// Inserts the given group to attacker group and sends it /// to target destination and recalculates the group. /// </summary> /// <param name="group">The inserting group.</param> public void AddGroup(GroupMovables group) { GroupManager groupMgr = Game.GroupManager; Game.IMoveManager.GoToTarget(group, target); int groupCount = group.Count; for (int i = 0; i < groupCount; i++) { IMovableGameObject temp = group[0]; groupMgr.RemoveFromGroup(temp); groupMgr.AddToGroup(attackers, temp); } attackers.Reselect(); groupMgr.SelectGroup(attackers); }
/// <summary> /// Finds required group by the given object. If it is not exists so the new is created /// just with given object. /// </summary> /// <param name="imgo">The object which the group is looking for.</param> /// <returns>Returns the founded group or a new one</returns> public GroupMovables GetGroup(IMovableGameObject imgo) { GroupMovables group; if (imgoGroupDict.ContainsKey(imgo)) { group = imgoGroupDict[imgo]; } else { group = new GroupMovables(imgo.Team); group.InsertMemeber(imgo); imgoGroupDict.Add(imgo, group); } return(group); }
/// <summary> /// Removes moveble object from its Team. /// </summary> /// <param name="imgo">The removing moveble object.</param> public void RemoveFromOwnTeam(IMovableGameObject imgo) { imgo.Team.RemoveIMGO(imgo); }
/// <summary> /// Removes the object from the old Team and inserts it to the given Team. /// </summary> /// <param name="imgo">The removing movable object.</param> /// <param name="newTeam">The new Team of the movable object.</param> public void ChangeTeam(IMovableGameObject imgo, Team newTeam) { RemoveFromOwnTeam(imgo); newTeam.AddIMGO(imgo); }
/// <summary> /// Just recieves the information and does nothing. /// </summary> /// <param name="imgo">The object which reached the destination.</param> public void MovementFinished(IMovableGameObject imgo) { }
/// <summary> /// Initializes the FightManager from two given lists (occupation and fights). /// </summary> /// <param name="loadedOcc">The list with occupations.</param> /// <param name="loadedFights">The list with fights.</param> public void Initialize(List <Tuple <List <string>, string, int> > loadedOcc, List <Tuple <List <string>, List <string> > > loadedFights) { // Occupations if (loadedOcc != null) { foreach (var occupation in loadedOcc) { IMovableGameObject firstObj = null; foreach (var gameObject in occupation.Item1) { if (Game.HitTest.IsObjectControllable(gameObject) && Game.HitTest.IsObjectMovable(gameObject)) { firstObj = Game.HitTest.GetIMGO(gameObject); break; } } if (firstObj == null) { // Invalid data continue; } GroupMovables group = Game.GroupManager.GetGroup(firstObj); // Creates group for (int i = 1; i < occupation.Item1.Count; i++) { if (Game.HitTest.IsObjectControllable(occupation.Item1[i]) && Game.HitTest.IsObjectMovable(occupation.Item1[i])) { Game.GroupManager.AddToGroup(group, Game.HitTest.GetIMGO(occupation.Item1[i])); } } if (group.Count == 0) { // Invalid data continue; } IGameObject target; if (Game.HitTest.IsObjectControllable(occupation.Item2)) { target = Game.HitTest.GetGameObject(occupation.Item2); } else { // Invalid data continue; } if (target.OccupyTime == occupation.Item3) { Occupy(group, target); } else { // Create Occupation occupationList.Add(new Occupation(group, target, TimeSpan.FromSeconds(occupation.Item3))); } } } // Fights if (loadedFights != null) { foreach (var fight in loadedFights) { var firstObj = Game.HitTest.GetIMGO(fight.Item1[0]); GroupMovables group1 = Game.GroupManager.GetGroup(firstObj); // Creates group1 for (int i = 1; i < fight.Item1.Count; i++) { if (Game.HitTest.IsObjectControllable(fight.Item1[i]) && Game.HitTest.IsObjectMovable(fight.Item1[i])) { Game.GroupManager.AddToGroup(group1, Game.HitTest.GetIMGO(fight.Item1[i])); } } if (group1.Count == 0) { continue; } // Second group can contains the static members IGameObject firstObj1 = null; GroupMovables group2 = null; foreach (var gameObject in fight.Item2) { if (Game.HitTest.IsObjectControllable(gameObject)) { firstObj1 = Game.HitTest.GetGameObject(gameObject); group2 = new GroupMovables(firstObj1.Team); break; } } GroupStatics group3 = new GroupStatics(); if (Game.HitTest.IsObjectControllable(fight.Item2[0])) { if (Game.HitTest.IsObjectMovable(fight.Item2[0])) { var firstObj2 = Game.HitTest.GetIMGO(fight.Item2[0]); group2 = Game.GroupManager.GetGroup(firstObj2); } else { var firstObj3 = Game.HitTest.GetISGO(fight.Item2[0]); group3 = new GroupStatics(firstObj3.Team); group3.InsertMemeber(firstObj3); } } if (group2 == null || group3 == null || group2.Count == 0 && group3.Count == 0) { // Invalid data continue; } for (int i = 1; i < fight.Item2.Count; i++) { if (Game.HitTest.IsObjectMovable(fight.Item2[i])) { Game.GroupManager.AddToGroup(group2, Game.HitTest.GetIMGO(fight.Item2[i])); } else { group3.InsertMemeber(Game.HitTest.GetISGO(fight.Item2[i])); } } fightList.Add(new Fight(group1, group2, group3)); } } }
/// <summary> /// Removes given object from attackes targets. If the removing object is the actual /// target then selects new one. /// </summary> /// <param name="igo">The removing target.</param> private void RemoveFromAttackerTarget(IMovableGameObject igo) { imgoDeffenders.RemoveMember(igo); if (attackerTarget.Value == igo) { SelectAttackerTarget(); } }
/// <summary> /// Removes given object from deffenders targets. If the removing object is the actual /// target then selects new one. Also controls if exist any next attacker (if not fight ends). /// </summary> /// <param name="igo">The removing target.</param> private void RemoveFromDeffenderTarget(IMovableGameObject igo) { groupAttackers.RemoveMember(igo); if (deffenderTarget.Value == igo) { if (groupAttackers.Count != 0) { deffenderTarget.Value = groupAttackers[0]; } else { EndFight(); } } }
/// <summary> /// Recieves information when object reached the destination. Checks if object is attacking or occupying and /// creates the appropriate class. /// </summary> /// <param name="imgo">The object in destiantion.</param> public void MovementFinished(IMovableGameObject imgo) { var onWayCopy = new Dictionary<IMovableGameObject, GroupMovables>(onWayToTargetDict); var group = onWayCopy[imgo]; var gameObject = attackersTarget[imgo]; var moveMgr = Game.IMoveManager; // Remove all object which goint to the same target from a watch lists. foreach (IMovableGameObject item in onWayCopy[imgo]) { onWayToTargetDict.Remove(item); attackersTarget.Remove(item); moveMgr.UnlogFromFinishMoveReciever(item); } if (offensiveActionDict[onWayCopy[imgo]] == ActionAnswer.Attack) { // Creates a Fight fightList.Add(new Fight(group, gameObject)); } else { // Creates an Occupation occupationList.Add(new Occupation(group, gameObject)); } offensiveActionDict.Remove(onWayCopy[imgo]); }
/// <summary> /// Adds new object to imgoDict and also adds to objectIsMovable as movable (true). /// </summary> /// <param name="imgo">The inserting object.</param> public void RegisterIMGO(IMovableGameObject imgo) { objectIsMovable.Add(imgo.Name, true); imgoDict.Add(imgo.Name, imgo); }
/// <summary> /// Shows panel with possible travel destiantions (ShowTravelDestinations). /// </summary> /// <param name="target">The target which invoke this calling.</param> public override void TargetInSight(IMovableGameObject target) { ShowTravelDestinations(target); }
/// <summary> /// Sends object to the given position. /// </summary> /// <param name="imgo">The moving game object.</param> /// <param name="to">The point of the moving.</param> public void GoToLocation(IMovableGameObject imgo, Mogre.Vector3 to) { var a = new LinkedList<Mogre.Vector3>(); a.AddLast(to); imgo.SetNextLocation(a); }
/// <summary> /// Receives information that the object interupted movement. /// Does nothing with this object. /// </summary> /// <param name="imgo">The object interupted movement.</param> public void MovementInterupted(IMovableGameObject imgo) { }
/// <summary> /// Sends the movable object to the position and registers the object to controlled movements. /// </summary> /// <param name="imgo">The movable object which is sended to the position of the game object.</param> /// <param name="gameObject">The object where the movable object goes.</param> /// <param name="reciever">The IFinishMovementReciever for the movable object.</param> public void GoToTarget(IMovableGameObject imgo, IGameObject gameObject, IFinishMovementReciever reciever) { imgo.GoToTarget(gameObject); moveMgrControledDict.Add(imgo, gameObject); finishMoveRecDict.Add(imgo, reciever); }
/// <summary> /// Doesn't react on the target in sight (objects should override). /// </summary> /// <param name="target">The target which invoke this calling.</param> public virtual void TargetInSight(IMovableGameObject target) { }
/// <summary> /// Receives information that the object reached the destiantion. /// </summary> /// <param name="imgo">The object in destination.</param> public void MovementFinished(IMovableGameObject imgo) { movingDict.Remove(imgo); imgo.StartAttack(this); }
/// <summary> /// Sends the given object to the given position. /// </summary> /// <param name="imgo">The IMovableGameObject which is sended to the destiantion.</param> /// <param name="target">The object where the group goes.</param> private void GoToTargetIMGO(IMovableGameObject imgo, IGameObject target) { imgo.GoToTarget(target); moveMgrControledDict.Add(imgo, target); }
/// <summary> /// Adds new object to the imgoDict and also adds to the objectIsMovable as a movable (true). /// </summary> /// <param name="imgo">The inserting object.</param> public void RegisterIMGO(IMovableGameObject imgo) { objectIsMovable.Add(imgo.Name, true); imgoDict.Add(imgo.Name, imgo); }
/// <summary> /// Check if SolarSystem contains the IMovableGameObject. /// </summary> /// <param name="imgo">The checking object.</param> /// <returns>Returns if the SolarSystem contains the object.</returns> public bool HasIMGO(IMovableGameObject imgo) { return imgoObjectDict.ContainsKey(imgo.Name); }
/// <summary> /// Removes movable game object from group, from solar system and calls Destroy to remove object from the game. /// </summary> /// <param Name="gameObject">IMovableGameObject to remove from the game.</param> public void DestroyGameObject(IMovableGameObject imgo) { RemoveFromGroup(imgo); imgo.Destroy(); Game.SolarSystemManager.RemoveObjectFromSolarSystem(imgo); }
/// <summary> /// Finds required group by given object. If it is not exists so the new is created /// just with given object. /// </summary> /// <param name="imgo">The object which the group is looking for.</param> /// <returns></returns> public GroupMovables GetGroup(IMovableGameObject imgo) { GroupMovables group; if (imgoGroupDict.ContainsKey(imgo)) { group = imgoGroupDict[imgo]; } else { group = new GroupMovables(imgo.Team); group.InsertMemeber(imgo); imgoGroupDict.Add(imgo, group); } return group; }
/// <summary> /// Shows GUI panel with possible travel destiantions and playes a portal animation. /// </summary> /// <param name="imgo"></param> public void ShowTravelDestinations(IMovableGameObject imgo) { Game.CreateInterstellarTravel(imgo); isPorting = true; portTimeDuration = portTime; }