/// <summary> /// Factory method to create CharacterControllers /// </summary> /// <param name="ci">Information about character apperance and stats</param> /// <param name="startpos">Where in the Area the character should be placed</param> /// <param name="playerControlled">True if the character should be a PC, false if NPC</param> /// <returns>Constructed CharacterController</returns> public static CharacterController construct(CharacterInfo ci, Vector2 startpos, bool playerControlled, int npcID) { CharacterController cc; ColliderType type; if (playerControlled) { cc = new PlayerController(); type = ColliderType.PC; } else { cc = new CharacterController(); type = ColliderType.NPC; } cc.m_npc_id = npcID; cc.m_position = startpos; cc.AnimationController = new AnimationController(ci.animationDataPath, ci.animationTexturePath); cc.AnimationController.ActionTriggered += new ActionTriggeredEventHandler(cc.handleAction); cc.AnimationController.Scale = ci.scale; Rectangle bounds = ci.collisionBox; bounds.Offset((int)cc.m_position.X, (int)cc.m_position.Y); cc.m_collider = new Collider(cc, bounds, type, cc.m_npc_id); cc.m_speed = ci.speed; cc.m_previousAngle = (float)Math.PI / 2; return cc; }
/// <summary> /// Factory method to create CharacterControllers /// </summary> /// <param name="ci">Information about character apperance and stats</param> /// <param name="startpos">Where in the Area the character should be placed</param> /// <param name="playerControlled">True if the character should be a PC, false if NPC</param> /// <returns>Constructed CharacterController</returns> public static CharacterController construct(CharacterInfo ci, Vector2 startpos, Constants.CharType typeOfChar, PlayerController p) { CharacterController cc; cc = new CharacterController(); cc.m_doodadIndex = 0; ColliderType type; if (typeOfChar == Constants.CharType.PLAYERCHAR) { cc = new PlayerController(); type = ColliderType.PC; cc.m_doodadIndex = Constants.PLAYER; cc.bouncer = null; cc.brew = new Brew(0, 0); currPlan = null;// new ActionNode(ActionNode.EMPTY); } else if (typeOfChar == Constants.CharType.NPCHAR) { type = ColliderType.NPC; cc.bouncer = null; cc.brew = null; } else { cc = new CompanionController(p); type = ColliderType.PC; cc.m_doodadIndex = Constants.COMPANION; cc.bouncer = null; cc.brew = new Brew(0, 0); } cc.m_position = startpos; cc.AnimationController = new AnimationController(ci.animationDataPath, ci.animationTexturePath); cc.AnimationController.ActionTriggered += new ActionTriggeredEventHandler(cc.handleAction); cc.AnimationController.Scale = ci.scale; Rectangle bounds = ci.collisionBox; bounds.Offset((int)cc.m_position.X, (int)cc.m_position.Y); cc.m_collider = new Collider(cc, bounds, type); cc.m_speed = ci.speed; //if(PCControllerInput. cc.m_previousAngle = (float)Math.PI / 2; cc.victim = -1; cc.social_game = null; cc.walking = false; cc.walk_target = -1; cc.walk_dir = -1; cc.distance = 0; return cc; }
/// <summary> /// Factory method to construct non-player character controllers /// See other construct() method for more details /// </summary> public static CharacterController construct(CharacterInfo ci, Vector2 startpos, int npc_id) { return construct(ci, startpos, false, npc_id); }
/// <summary> /// Factory method to construct non-player character controllers /// See other construct() method for more details /// </summary> public static CharacterController construct(CharacterInfo ci, Vector2 startpos) { return construct(ci, startpos, Constants.CharType.NPCHAR, null); }