public TestOldMan(int playerNumber = 0) { mPlayerNumber = playerNumber; mPosition = new PositionComponent(this, 100, 100); mRotation = new RotationComponent(this); //mRenderable = new RenderableComponent(this); mPhysics = new PhysicsComponent(this); mAnimated = new AnimatedComponent(this); mInput = new InputComponent(this); mController = new PlayerControllerComponent(this); mHealth = new HealthComponent(this, 100.0f); }
public TestNess(int playerNumber = 0) { mPlayerNumber = playerNumber; mPosition = new PositionComponent(this, 100, 100); mRotation = new RotationComponent(this); //mRenderable = new RenderableComponent(this); mPhysics = new PhysicsComponent(this); mAnimated = new AnimatedComponent(this); mInput = new InputComponent(this); mController = new PlayerControllerComponent(this); //switch (mPlayerNumber) //{ // case 0: // // Player 0 means no human control. // break; // case 1: // mInput.PlayerIndex = PlayerIndex.One; // break; // case 2: // mInput.PlayerIndex = PlayerIndex.Two; // break; // case 3: // mInput.PlayerIndex = PlayerIndex.Three; // break; // case 4: // mInput.PlayerIndex = PlayerIndex.Four; // break; //} mHealth = new HealthComponent(this, 100.0f); }
/// <summary> /// /// </summary> /// <param name="currentKey"></param> /// <param name="framesOnKey"></param> /// <param name="rect"></param> /// <param name="script"></param> /// <param name="direction"></param> /// <param name="spriteFlipped"></param> /// <param name="reversed"></param> public virtual void GetFrameInfo(ref int currentKey, ref int framesOnKey, ref FloatRectangle rect, ref Script script, RotationComponent.CardinalDirections direction, out bool spriteFlipped,bool reversed = false) { framesOnKey++; if (framesOnKey > mFrameDurations[currentKey]) { framesOnKey = 0; if (reversed) { currentKey--; if (currentKey < 0) { currentKey = mFrames[DirectionMap[RotationComponent.CardinalDirections.N]].Count - 1; } } else { currentKey++; if (currentKey > mFrames[DirectionMap[RotationComponent.CardinalDirections.N]].Count - 1) { currentKey = 0; } } } if (mFrames.Count == 1) { rect = mFrames[RotationComponent.CardinalDirections.NONE][currentKey]; } else { rect = mFrames[mDirectionMap[direction]][currentKey]; } if (direction > RotationComponent.CardinalDirections.S && mDirectionMap[RotationComponent.CardinalDirections.SW] != RotationComponent.CardinalDirections.SW) { spriteFlipped = true; } else { spriteFlipped = false; } script.AddRange(mWholeAnimationScript); if (mFrameScripts.ContainsKey(currentKey)) { script.AddRange(mFrameScripts[currentKey]); } }
/// <summary> /// /// </summary> /// <param name="direction"></param> /// <param name="frame"></param> /// <param name="index"></param> public void AddFrame(RotationComponent.CardinalDirections direction, FloatRectangle frame, int index) { // Add a keyframe dictionary if one doesn't exist for the specified direction. if(mFrames.ContainsKey(direction) == false) { mFrames.Add(direction, new KeyFrameDictionary()); } if (mFrames[direction].ContainsKey(index)) { mFrames[direction][index] = frame; } else { mFrames[direction].Add(index, frame); } // Make sure a script exists for this keyframe index if(mFrameScripts.ContainsKey(index) == false) { mFrameScripts.Add(index, new Script()); } if (direction == RotationComponent.CardinalDirections.NONE) { foreach (RotationComponent.CardinalDirections animDirection in Enum.GetValues(typeof(RotationComponent.CardinalDirections))) { mDirectionMap[animDirection] = RotationComponent.CardinalDirections.NONE; } } }