public static void initialize(EngineStateGameplay esg, PlayerController pc, Area startArea) { GameplayState = esg; playerController = pc; activeArea = startArea; activeArea.add(pc); }
public CompanionController(PlayerController p) { // nch, should only be called by CharacterController.construct player = p; isLearning = false; learnedPlan = new ActionNode(ActionNode.EMPTY); currentGoal = null; currentGoalID = -1; walking = false; distance = 0; walk_dir = 0; walk_target = -1; interacting = false; invalids = new List<int>(); is_init = false; //last_walk_target = -1; ///debug //learnedPlan.addLeaf(new ActionNode(new Brew(Brew.COLOR_RED, 0))); }
/// <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; }