/// <summary> /// Call this to initialize a Behaviour with data supplied in a file. /// </summary> /// <param name="fileName">The file to load from.</param> public override void LoadContent(String fileName) { base.LoadContent(fileName); mCurrentFollowType = FollowType.None; mExplodeDistanceSqr = 8 * 8; mBLineDistanceSqr = 40 * 40; mCloseRangeDistanceSqr = 88 * 88; mFrozenDistanceSqr = 160 * 160; mMoveSpeedPathFinding = 0.8f; mMoveSpeedDirectApproach = 0.5f; mMoveSpeedBLine = mMoveSpeedDirectApproach * 1.5f; mForceBLine = false; mBLineTimer = StopWatchManager.pInstance.GetNewStopWatch(); mBLineTimer.pLifeTime = 120.0f; mBLineTimer.pIsPaused = true; mBLineTimer.SetUpdatePass(MBHEngineContentDefs.BehaviourDefinition.Passes.DEFAULT); // Allocate these ahead of time to avoid triggering GC. mSetDestinationMsg = new PathFind.SetDestinationMessage(); mSetSourceMsg = new PathFind.SetSourceMessage(); mGetCurrentBestNodeMsg = new PathFind.GetCurrentBestNodeMessage(); mClearDestinationMsg = new PathFind.ClearDestinationMessage(); mDetonateMsg = new Explosive.DetonateMessage(); mIncrementScoreMsg = new PlayerScore.IncrementScoreMessage(); mSetActiveAnimMsg = new SpriteRender.SetActiveAnimationMessage(); mSetTargetObjectMsg = new PathFollow.SetTargetObjectMessage(); }
/// <summary> /// Constructor. /// </summary> /// <param name="def">Defines how this Button should be initialized.</param> public Button(StrandedPopupDefinition.ButtonDefinition def) { // Create the icon to show on the button. mObject = new GameObject(def.mIconFileName); // All buttons use the same background image for now. mBG = new GameObject("GameObjects\\Interface\\StrandedPopup\\IconBG\\IconBG"); mBG.pPosition = mObject.pPosition; mCrossOut = new GameObject("GameObjects\\Interface\\StrandedPopup\\IconX\\IconX"); mCrossOut.pPosition = mObject.pPosition; mCrossOut.pDoRender = false; // By default a Button has no siblings. mLeft = mRight = null; mType = def.mButtonType; mHintText = def.mHintText; mEnabled = true; mSetActiveAnimationMsg = new SpriteRender.SetActiveAnimationMessage(); mGetGunLevelsRemainingMsg = new GunStatBoostResearch.GetGunLevelsRemainingMessage(); mGetHealthLevelsRemainingMsg = new HealthStatBoostResearch.GetHealthLevelsRemainingMessage(); mGetIsScoutableMsg = new GetIsScoutableMessage(); }
/// <summary> /// Constructor. /// </summary> public FSMStatePatrol() { mSetTargetObjectMsg = new PathFollow.SetTargetObjectMessage(); mGetTileAtPositionMsg = new Level.GetTileAtPositionMessage(); mSetDestinationMsg = new PathFind.SetDestinationMessage(); mSetSourceMsg = new PathFind.SetSourceMessage(); mSetActiveAnimationMsg = new SpriteRender.SetActiveAnimationMessage(); mSetStateMsg = new FiniteStateMachine.SetStateMessage(); }
/// <summary> /// Constructor. /// </summary> public FSMStateDoRepair() { mHpRepairRate = 0.01f; mSetActiveAnimationMsg = new SpriteRender.SetActiveAnimationMessage(); mGetTileToRepairMsg = new FSMEngineer.GetTileToRepairMessage(); mIncrementHealthMsg = new Health.IncrementHealthMessage(); mGetHealthMsg = new Health.GetHealthMessage(); }
/// <summary> /// Constructor. /// </summary> public FSMStateWaitAtStandingPosition(String popupScript) { mPopupScript = popupScript; mSetActiveAnimationMsg = new SpriteRender.SetActiveAnimationMessage(); mGetTileAtObjectMsg = new Level.GetTileAtObjectMessage(); mGetAttachmentPointMsg = new SpriteRender.GetAttachmentPointMessage(); mOnPopupCloseMsg = new StrandedPopup.OnPopupClosedMessage(); mSetStateMsg = new FiniteStateMachine.SetStateMessage(); }
/// <summary> /// Constructor. /// </summary> public FSMStateGoToExtraction() { mSetActiveAnimationMsg = new SpriteRender.SetActiveAnimationMessage(); mSetDestinationMsg = new PathFind.SetDestinationMessage(); mSetSourceMsg = new PathFind.SetSourceMessage(); mGetCurrentBestNodeMsg = new PathFind.GetCurrentBestNodeMessage(); mGetExtractionPointMsg = new ZombieTaxi.Behaviours.FSMCivilian.GetExtractionPointMessage(); mIncrementScoreMsg = new PlayerScore.IncrementScoreMessage(); mIncrementScoreMsg.mAmount_In = 500; mClearDestinationMsg = new PathFind.ClearDestinationMessage(); mSetTargetObjectMsg = new PathFollow.SetTargetObjectMessage(); mSetStateMsg = new FiniteStateMachine.SetStateMessage(); }
/// <summary> /// Call this to initialize a Behaviour with data supplied in a file. /// </summary> /// <param name="fileName">The file to load from.</param> public override void LoadContent(String fileName) { base.LoadContent(fileName); StrandedPopupDefinition def = GameObjectManager.pInstance.pContentManager.Load <StrandedPopupDefinition>(fileName); // All versions of the Stranded popup use the same Window and Cursor. mWindow = new GameObject("GameObjects\\Interface\\StrandedPopup\\Window\\Window"); mCursor = new GameObject("GameObjects\\Interface\\StrandedPopup\\Cursor\\Cursor"); // Create the font for displaying the hint text. mFont = GameObjectManager.pInstance.pContentManager.Load <SpriteFont>("Fonts\\Retro"); mButtons = new List <Button>(def.mButtons.Count); mCurrentButton = null; // Popups should all be in the same position along with their buttons so just hard code some values. Vector2 center = new Vector2(80.0f, 10.0f); // The space between each button. const Single spacing = 11.0f; // Calculate the position where the first button should go. We will move right from their\ // at a rate of spacing. Single start = center.X - ((def.mButtons.Count - 1) * 0.5f * spacing); for (Int32 i = 0; i < def.mButtons.Count; i++) { // Create all the Buttons. Button temp = new Button(def.mButtons[i]); mButtons.Add(temp); // Special property which moves the button and all its children (eg. the background). temp.pPosition = new Vector2(start + (i * spacing), center.Y); // Select the first Button by default. if (mCurrentButton == null) { mCurrentButton = temp; } else { // If this isn't the first Button than link it to the previous one. temp.LinkLeft(mButtons[i - 1]); } } mSetActiveAnimationMsg = new SpriteRender.SetActiveAnimationMessage(); mOnPopupCloseMsg = new OnPopupClosedMessage(); }
/// <summary> /// Constructor. /// </summary> public FSMStateGoToStandingPosition() { mValidSafeHouses = new List <GameObject>(100); mSetActiveAnimationMsg = new SpriteRender.SetActiveAnimationMessage(); mSetDestinationMsg = new PathFind.SetDestinationMessage(); mSetSourceMsg = new PathFind.SetSourceMessage(); mGetCurrentBestNodeMsg = new PathFind.GetCurrentBestNodeMessage(); mClearDestinationMsg = new PathFind.ClearDestinationMessage(); mSetTargetObjectMsg = new PathFollow.SetTargetObjectMessage(); mSetStateMsg = new FiniteStateMachine.SetStateMessage(); mGetTileAtObjectMsg = new Level.GetTileAtObjectMessage(); mIncrementScoreMsg = new PlayerScore.IncrementScoreMessage(); mGetSafeHouseScoreMessage = new Behaviours.FSMCivilian.GetSafeHouseScoreMessage(); }
/// <summary> /// Constructor. /// </summary> public FSMStateRepair() { mDamagedTiles = new List <Level.Tile>(16); mFoundTileObjects = new List <GameObject>(1); mTileClassifications = new List <GameObjectDefinition.Classifications>(1); mTileClassifications.Add(GameObjectDefinition.Classifications.WALL); mSetTargetObjectMsg = new PathFollow.SetTargetObjectMessage(); mGetTileAtPositionMsg = new Level.GetTileAtPositionMessage(); mSetDestinationMsg = new PathFind.SetDestinationMessage(); mSetSourceMsg = new PathFind.SetSourceMessage(); mSetActiveAnimationMsg = new SpriteRender.SetActiveAnimationMessage(); mSetStateMsg = new FiniteStateMachine.SetStateMessage(); mGetHealthMsg = new Health.GetHealthMessage(); mSetTileToRepairMsg = new FSMEngineer.SetTileToRepairMessage(); }
/// <summary> /// Call this to initialize a Behaviour with data supplied in a file. /// </summary> /// <param name="fileName">The file to load from.</param> public override void LoadContent(String fileName) { base.LoadContent(fileName); TwinStickDefinition def = GameObjectManager.pInstance.pContentManager.Load <TwinStickDefinition>(fileName); mMoveSpeed = def.mMoveSpeed; mGun = new GameObject("GameObjects\\Items\\Gun\\Gun"); GameObjectManager.pInstance.Add(mGun); mGun.pPosition = mParentGOH.pPosition; mGun.pPosX = mGun.pPosX + 1.0f; //mGun.pPosition.Y = mGun.pPosition.Y + 4.5f; mGunCooldown = StopWatchManager.pInstance.GetNewStopWatch(); mGunCooldown.pLifeTime = 5; // 1 bullet fired every 5 frames. mGrenadeCooldown = StopWatchManager.pInstance.GetNewStopWatch(); mGrenadeCooldown.pLifeTime = 60; mSafeHousePlaced = false; mGunLevel = 0; mGOFloodFill = new GameObjectFloodFill(); mGunLevelInfo = new GunLevelInfo[] { new GunLevelInfo(1.0f, 1.0f, 1.0f), new GunLevelInfo(2.0f, 1.5f, 1.1f), new GunLevelInfo(4.0f, 1.5f, 1.2f), new GunLevelInfo(7.0f, 1.5f, 1.3f), new GunLevelInfo(11.0f, 1.5f, 1.4f), new GunLevelInfo(16.0f, 2.0f, 1.5f), }; mSpriteFxMsg = new SpriteRender.SetSpriteEffectsMessage(); mGetSpriteFxMsg = new SpriteRender.GetSpriteEffectsMessage(); mSpriteActiveAnimMsg = new SpriteRender.SetActiveAnimationMessage(); mSetExtractionPointActivateMsg = new ExtractionPoint.SetExtractionPointActivateMessage(); mGetAttachmentPointMsg = new SpriteRender.GetAttachmentPointMessage(); mGetTileAtObjectMsg = new Level.GetTileAtObjectMessage(); mSetDamageModifierMessage = new Explosive.SetDamageMultiplierMessage(); }
/// <summary> /// Constructor. /// </summary> public FSMStateFollowTarget(String animationName) { mAnimationName = animationName; // We need to detect when the GameObject reaches a safe house and to do so we need // to do a collision check against all objects of a particular classification, in this // case "SAFE_HOUSE". We preallocate the two lists needed to do the check to avoid // triggering the GC. mSafeHouseInRange = new List <GameObject>(16); mSafeHouseClassifications = new List <GameObjectDefinition.Classifications>(); mSafeHouseClassifications.Add(GameObjectDefinition.Classifications.SAFE_HOUSE); mSetActiveAnimationMsg = new SpriteRender.SetActiveAnimationMessage(); mSetDestinationMsg = new PathFind.SetDestinationMessage(); mSetSourceMsg = new PathFind.SetSourceMessage(); mGetCurrentBestNodeMsg = new PathFind.GetCurrentBestNodeMessage(); mClearDestinationMsg = new PathFind.ClearDestinationMessage(); mIncrementScoreMsg = new PlayerScore.IncrementScoreMessage(); mSetTargetObjectMsg = new PathFollow.SetTargetObjectMessage(); mGetTileAtObjectMsg = new Level.GetTileAtObjectMessage(); mGetSafeHouseScoreMessage = new Behaviours.FSMCivilian.GetSafeHouseScoreMessage(); mSetStateMsg = new FiniteStateMachine.SetStateMessage(); }
/// <summary> /// Call this to initialize a Behaviour with data supplied in a file. /// </summary> /// <param name="fileName">The file to load from.</param> public override void LoadContent(String fileName) { base.LoadContent(fileName); ExplosiveDefinition def = GameObjectManager.pInstance.pContentManager.Load <ExplosiveDefinition>(fileName); mExplosionEffect = def.mEffectFileName; mExplosionAnimationNames = def.mAnimationsToPlay; mManualExplosion = def.mManualExplosion; mDamagedCaused = def.mDamageCaused; mDamageAppliedTo = new List <GameObjectDefinition.Classifications>(); for (Int32 i = 0; i < def.mDamageAppliedTo.Count; i++) { mDamageAppliedTo.Add(def.mDamageAppliedTo[i]); } mObjectsInRange = new List <GameObject>(16); if (def.mDetonationTimerDuration != 0) { mDetonationTimer = StopWatchManager.pInstance.GetNewStopWatch(); mDetonationTimer.pLifeTime = def.mDetonationTimerDuration; } mSetActiveAnimationMessage = new SpriteRender.SetActiveAnimationMessage(); mApplyDamageMsg = new Health.ApplyDamageMessage(); mApplyDamageMsg.mDamageAmount_In = mDamagedCaused; mGetAttachmentPointMsg = new SpriteRender.GetAttachmentPointMessage(); Reset(); }
/// <summary> /// Constructor. /// </summary> public FSMStateWaitForRepairChance() { mSetActiveAnimationMsg = new SpriteRender.SetActiveAnimationMessage(); }
/// <summary> /// Constructor. /// </summary> public FSMStatePauseAtPatrolPoint() { mSetActiveAnimationMsg = new SpriteRender.SetActiveAnimationMessage(); }
/// <summary> /// Constructor. /// </summary> public FSMStateStay() { mSetActiveAnimationMsg = new SpriteRender.SetActiveAnimationMessage(); }
/// <summary> /// Constructor. /// </summary> public FSMStateWaitAtTarget() { mGetAttachmentPointMsg = new SpriteRender.GetAttachmentPointMessage(); mSetActiveAnimationMsg = new SpriteRender.SetActiveAnimationMessage(); mSetStateMsg = new FiniteStateMachine.SetStateMessage(); }
/// <summary> /// Constructor. /// </summary> public FSMStateCower(String animName) { mAnimationName = animName; mSetActiveAnimationMsg = new SpriteRender.SetActiveAnimationMessage(); }