public bool MindEquals(IMind mind1, IMind mind2) { if (mind1.GetType() == mind2.GetType()) { bool returnvalue = true; if (mind1.GetType() == typeof(Gathering)) { Gathering gather = (Gathering)mind1; Gathering gather2 = (Gathering)mind2; if (!(gather.prefferedType == gather2.prefferedType && gather.prefferedDirection == gather2.prefferedDirection && gather.carryWeight == gather2.carryWeight && gather.IsScout == gather2.IsScout)) { returnvalue = false; } } if (mind1.GetType() == typeof(CombatMind)) { CombatMind combat = (CombatMind)mind1; CombatMind combat2 = (CombatMind)mind2; if (!(combat.GetMinEstimatedDifference() == combat2.GetMinEstimatedDifference() && combat.GetPrefferedHealth() == combat2.GetPrefferedHealth())) { returnvalue = false; } } return(returnvalue); } return(false); }
/// <summary> /// Using generic class T, create a mind of type T /// </summary> /// <typeparam name="T">IMind or subclass of IMind</typeparam> public IMind Create <T>() where T : IMind, new() { mind = new T(); mindNumber++; //if (mind.getSetName == "PlayerMind") //{ // playerMindNumber++; // mind.getSetNumber = playerMindNumber; //} //else if (mind.getSetName == "CameraMind") //{ // cameraMindNumber++; // mind.getSetNumber = cameraMindNumber; //} //else if (mind.getSetName == "GhostMind") //{ // ghostMindNumber++; // mind.getSetNumber = ghostMindNumber; //} //else if (mind.getSetName == "PatientMind") //{ // patientMindNumber++; // mind.getSetNumber = patientMindNumber; //} //mind.getSetID = mind.getSetName + mind.getSetNumber; //AddToDict(mind.getSetID, mind); return(mind); }
public override void RunBehaviour(IMind mind, Vector2 v) { // Left if (v.X == -1) { mind.getSetStateMachine.getSetCurrentState = BehaviourM.getInstance.GetState("WalkLeft"); } // Right else if (v.X == 1) { mind.getSetStateMachine.getSetCurrentState = BehaviourM.getInstance.GetState("WalkRight"); } // Down else if (v.Y == 1) { mind.getSetStateMachine.getSetCurrentState = BehaviourM.getInstance.GetState("WalkDown"); } // Up else if (v.Y == -1) { mind.getSetStateMachine.getSetCurrentState = BehaviourM.getInstance.GetState("WalkUp"); } else { //mind.getSetMoveVector = new Vector2(0, 0); if (PhysicsM.getInstance.getSetInputForce > 0) { PhysicsM.getInstance.getSetInputForce -= 1.5f; } //PhysicsM.getInstance.getSetInputForce = 0; } //Console.WriteLine("Idle passive... " + mind.getSetID); }
public GraphServices( IMind mind, IConnectionManager connectionManager, IPathFinder pathFinder, INodeManager nodeManager) { _mind = mind; _connectionManager = connectionManager; _pathFinder = pathFinder; _nodeManager = nodeManager; }
public AiPlayer(int id, double strength) { //CSScript.GlobalSettings.AddSearchDir(@"C:\Users\Slawek\Documents\GitHub\TripleTriadRefresh\TripleTriadRefresh.Server\bin\Debug\Scripts\Ai\"); //var ass = CSScript.Load(@"Mind.cs"); //this.mind = ass.CreateInstance("Mind", false, BindingFlags.CreateInstance, null, null, CultureInfo.InvariantCulture, null).AlignToInterface<IMind>(); this.mind = new Mind().AlignToInterface<IMind>(); this.strength = strength; DbEntity = new DbPlayer(); this.ConnectionId = Guid.NewGuid().ToString(); }
public override void RunBehaviour(IMind mind, Vector2 v) { // Down if (v.Y == 1) { // Down + Right if (v.X == 1) { mind.getSetMoveVector = new Vector2(1, 1); } // Down + Left else if (v.X == -1) { mind.getSetMoveVector = new Vector2(-1, 1); } // Down else { mind.getSetMoveVector = new Vector2(0, 1); } if (mind.getSetSpeed < 3) { PhysicsM.getInstance.getSetInputForce += 1f; } } // Up else if (v.Y == -1) { mind.getSetStateMachine.getSetPreviousState = this; mind.getSetStateMachine.getSetCurrentState = BehaviourM.getInstance.GetState("WalkUp"); } // Left else if (v.X == -1) { mind.getSetStateMachine.getSetPreviousState = this; mind.getSetStateMachine.getSetCurrentState = BehaviourM.getInstance.GetState("WalkLeft"); } // Right else if (v.X == 1) { mind.getSetStateMachine.getSetPreviousState = this; mind.getSetStateMachine.getSetCurrentState = BehaviourM.getInstance.GetState("WalkRight"); } else { mind.getSetStateMachine.getSetPreviousState = this; mind.getSetStateMachine.getSetCurrentState = BehaviourM.getInstance.GetState("Idle"); } //Console.WriteLine("WalkDown " + mind.getSetID); }
/// <summary> /// Using the string type, Returns a value from the mind with the key type /// </summary> /// <param name="type"></param> /// <returns></returns> public IMind getMind(string type) { IMind mind = null; // Search using the key string if (mindDict.ContainsKey(type)) { // Get the value from the key mind = mindDict[type]; } return(mind); }
/// <summary> /// Removes a key-value from the Dictionary /// </summary> /// <param name="type">key of value to be removed</param> public void Remove(string type) { // Search using the key string if (mindDict.ContainsKey(type)) { // Get the value from the key mind = mindDict[type]; } mind = null; GC.Collect(); }
public void Update(GameTime gameTime) { // FOREACH through each IUpdate in MindList foreach (IUpdate m in MindList) { // CALL to Update method on mind in list, passing in gameTime parameter m.Update(gameTime); // IF mind, cast as IMind, MindToRemove boolean is true if ((m as IMind).MindToRemove) { // THEN SET MindsToRemove to m (cast as a IMind) MindsToRemove = (m as IMind); } } }
/// <summary> /// Create an IEntity of type Player, create an IMind of type PlayerMind, link entity and mind, set location /// </summary> /// <param name="pLocation">Vector2, New location coordinates for the player entity</param> public void GeneratePlayer(Vector2 pLocation) { tempEntity = EntityM.getInstance.Create <Player>(); tempEntity.getSetNumber = 1; tempEntity.getSetID = tempEntity.getSetName + tempEntity.getSetNumber; EntityM.getInstance.AddToDict(tempEntity); tempMind = MindM.getInstance.Create <PlayerMind>(); tempMind.getSetNumber = 1; tempMind.getSetID = tempMind.getSetName + tempMind.getSetNumber; MindM.getInstance.AddToDict(tempMind); TargetM.getInstance.SetEntityToMind(EntityM.getInstance.getEntity("Player1"), MindM.getInstance.getMind("PlayerMind1")); // Location should be set in the FloorManager or MapManager or something EntityM.getInstance.getEntity("Player1").getSetLocation = pLocation; MindM.getInstance.getMind("PlayerMind1").SetValues(); }
/// <summary> /// Create IEntities and IMinds which will represent enemy characters, link the entity and the mind /// </summary> public void GenerateEnemies() { tempEntity = EntityM.getInstance.Create <Patient>(); tempEntity.getSetNumber = 1; tempEntity.getSetID = tempEntity.getSetName + tempEntity.getSetNumber; EntityM.getInstance.AddToDict(tempEntity); tempMind = MindM.getInstance.Create <PatientMind>(); tempMind.getSetNumber = 1; tempMind.getSetID = tempMind.getSetName + tempMind.getSetNumber; MindM.getInstance.AddToDict(tempMind); TargetM.getInstance.SetEntityToMind(EntityM.getInstance.getEntity("Patient1"), MindM.getInstance.getMind("PatientMind1")); Vector2 location = new Vector2(2250, 1450); EntityM.getInstance.getEntity("Patient1").getSetLocation = location; MindM.getInstance.getMind("PatientMind1").SetValues(); tempEntity = EntityM.getInstance.Create <Ghost>(); tempEntity.getSetNumber = 1; tempEntity.getSetID = tempEntity.getSetName + tempEntity.getSetNumber; EntityM.getInstance.AddToDict(tempEntity); tempMind = MindM.getInstance.Create <GhostMind>(); tempMind.getSetNumber = 1; tempMind.getSetID = tempMind.getSetName + tempMind.getSetNumber; MindM.getInstance.AddToDict(tempMind); TargetM.getInstance.SetEntityToMind(EntityM.getInstance.getEntity("Ghost1"), MindM.getInstance.getMind("GhostMind1")); location = new Vector2(3600, 1450); EntityM.getInstance.getEntity("Ghost1").getSetLocation = location; MindM.getInstance.getMind("GhostMind1").SetValues(); }
/// <summary> /// Method to remove a mind from the _mind List /// </summary> /// <param name="pMind"></param> public void RemoveMind(IMind pMind) { _mindList.Remove(pMind); }
private void UnloadMind(IMind e) { }
/// <summary> /// Uses the passed minds state machine to switch the current and previous state which is then applied to the mind /// </summary> /// <param name="mind">IMind which has changed states</param> /// <param name="fromState">The current state of the mind</param> /// <param name="toState">The next state of the mind</param> public void StateSwitcher(IMind mind, IState fromState, IState toState) { mind.getSetStateMachine.getSetPreviousState = fromState; mind.getSetStateMachine.getSetCurrentState = toState; }
public void Initialize(Vector2 Pos, string Tex) { mind = BehaviourManager.Instance.Create <SpikeTrap>(this); mind.Initialize(Pos, Tex); }
public void AddMind(IMind mind, int Position) { Minds[Position] = mind; }
/// <summary> /// Link the IEntity entity and the IMind mind /// </summary> /// <param name="entity">IEntity to be linked</param> /// <param name="mind">IMind to be linked</param> public void SetEntityToMind(IEntity entity, IMind mind) { entity.getSetMind = mind; mind.getSetEntity = entity; }
/// <summary> /// Sets entity mind /// </summary> /// <param name="pMind"></param> public virtual void SetMind(IMind pMind) { _mind = pMind; _mind.SetDelegates(this.Translate, this.InvertTexture, this.GetLocation); }
/// <summary> /// Adds a type IMind to the dictionary /// </summary> /// <param name="id">string, the key of the entry</param> /// <param name="mind">IMind, the value of the entry</param> public void AddToDict(string id, IMind mind) { mindDict.Add(id, mind); }
/// <summary> /// Adds a type IMind to the dictionary /// </summary> /// <param name="mind">IMind, the value of the entry</param> public void AddToDict(IMind mind) { mindDict.Add(mind.getSetID, mind); }
public MindComponent(IMind mind) { this.mind = mind; }
/// <summary> /// Initializes a new instance of the <see cref="BattleSnake"/> class. /// </summary> public BattleSnake(Snake snake, IMind mind) { this.snake = snake; this.mind = mind; SizeOfVisibleArea = 6; }
/// <summary> /// Sets entity mind /// </summary> /// <param name="pMind"></param> public virtual void SetMind(IMind pMind) { _mind = pMind; }
/// <summary> /// Create an IEntity of type Player, create an IMind of type PlayerMind, link entity and mind, set location /// </summary> public void GeneratePlayer(string floor) { tempEntity = EntityM.getInstance.Create <Player>(); tempEntity.getSetNumber = 1; tempEntity.getSetID = tempEntity.getSetName + tempEntity.getSetNumber; EntityM.getInstance.AddToDict(tempEntity); tempMind = MindM.getInstance.Create <PlayerMind>(); tempMind.getSetNumber = 1; tempMind.getSetID = tempMind.getSetName + tempMind.getSetNumber; MindM.getInstance.AddToDict(tempMind); TargetM.getInstance.SetEntityToMind(EntityM.getInstance.getEntity("Player1"), MindM.getInstance.getMind("PlayerMind1")); Vector2 location = new Vector2(); switch (floor) { case "TextMaps\\Floor0.txt": location = new Vector2(1472, 1700); break; case "TextMaps\\Floor1.txt": // Location should be set in the FloorManager or MapManager or something location = new Vector2(1700, 1700); break; case "TextMaps\\Floor2.txt": // Location should be set in the FloorManager or MapManager or something location = new Vector2(1700, 1700); break; case "TextMaps\\Floor3.txt": location = new Vector2(1700, 1700); break; case "TextMaps\\Chapel.txt": break; default: break; } EntityM.getInstance.getEntity("Player1").getSetLocation = location; MindM.getInstance.getMind("PlayerMind1").SetValues(); tempMind = MindM.getInstance.Create <CameraMind>(); tempMind.getSetNumber = 1; tempMind.getSetID = tempMind.getSetName + tempMind.getSetNumber; MindM.getInstance.AddToDict(tempMind); tempEntity = EntityM.getInstance.Create <Filter>(); tempEntity.getSetNumber = 1; tempEntity.getSetID = tempEntity.getSetName + tempEntity.getSetNumber; EntityM.getInstance.AddToDict(tempEntity); TargetM.getInstance.SetTargetToEntity((ITargetable)MindM.getInstance.getMind("CameraMind1"), EntityM.getInstance.getEntity("Player1")); }
public virtual void RunBehaviour(IMind mind, Vector2 v) { ICollidable mePhysical = (ICollidable)mind.getSetEntity; }