Example #1
0
        public ShipFbx(String modelName)
        {
            model = BeatShift.contentManager.Load <Model>("Models/Ships/" + modelName);


            SkinningData skd = GetSkinningDataFromTag();

            if (isAnimated)
            {
                clipPlayer = new ClipPlayer(skd, 24);
            }
            else
            {
                bones = new Matrix[model.Bones.Count];
                model.CopyAbsoluteBoneTransformsTo(bones);
            }

#if !DEBUG
            Utils.fixNullLightDirections(model);
#endif

            GC.Collect();

            //Override the default texture
            //Texture2D grayTexture;
            //grayTexture = content.Load<Texture2D>("tex5");
            //shipRenderer.Texture = grayTexture;
            //shipRenderer.TextureEnabled = true;
        }
Example #2
0
		protected override void Dispose(bool disposing)
		{
			if (ClipPlayer != null)
				ClipPlayer.Dispose();

			base.Dispose(disposing);
		}
Example #3
0
 void Start()
 {
     player      = FindObjectOfType <PlayerController>();
     clipPlayer  = FindObjectOfType <ClipPlayer>();
     audioSource = clipPlayer.GetComponent <AudioSource>();
     FetchHead();
 }
Example #4
0
    void PlayClickSound()
    {
        ClipPlayer ac = GameObject.Find("ClickSound").GetComponent <ClipPlayer>();

        clipLength = ac.GetClipLenght();
        ac.PlayClickSound();
    }
Example #5
0
 void Start()
 {
     rb          = GetComponent <Rigidbody>();
     head        = GetComponentInChildren <Head>();
     clipPlayer  = FindObjectOfType <ClipPlayer>();
     audioSource = clipPlayer.GetComponent <AudioSource>();
 }
Example #6
0
    public IEnumerator HandledHouse(House house, Vector2 local)
    {
        player.voice[2].Stop();
        currentStateName = "HandledHouse";
        while (true)
        {
            yield return(null);

            player.PositionInMap = house.LocalToMap(local);
            Position             = mapController.map.MapToWorldPoint(player.PositionInMap);
            Vector2Int side = house.PlayerSide(this);
            Dictionary <Vector2Int, string> sideAnimationNameMap = new Dictionary <Vector2Int, string>()
            {
                { new Vector2Int(-1, 0), "RightTop" },
                { new Vector2Int(1, 0), "LeftDown" },
                { new Vector2Int(0, 1), "RightDown" },
                { new Vector2Int(0, -1), "LeftTop" }
            };
            string clipName = sideAnimationNameMap[side];
            clipName += "Push";
            clipName += house.stateName == "Moving" ? "Walk" : "Stand";
            ClipPlayer.PlayClip(clipName);
            UnHandledInputProcess(house);
        }
    }
Example #7
0
        private void LoadKillers()
        {
            rasmus     = Content.Load <Model>("Models/rasmusFinal");
            hampus     = Content.Load <Model>("Models/hampusFinal");
            valter     = Content.Load <Model>("Models/valterFinal");
            axel       = Content.Load <Model>("Models/axelFinal5");
            rifleModel = Content.Load <Model>("Models/rifleHands1");
            gunPos     = riflePos;
            currentWep = rifleModel;

            hampusSkinningData = hampus.Tag as SkinningData;
            rasmusSkinningData = rasmus.Tag as SkinningData;
            axelSkinningData   = axel.Tag as SkinningData;
            valterSkinningData = valter.Tag as SkinningData;
            if (hampusSkinningData == null)
            {
                throw new InvalidOperationException
                          ("This model does not contain a SkinningData tag. Har du satt SkinnedModelProcessor? ");
            }
            Globals.hampusSkinningData = hampusSkinningData;
            Globals.rasmusSkinningData = rasmusSkinningData;
            Globals.axelSkinningData   = axelSkinningData;
            Globals.valterSkinningData = valterSkinningData;
            rifleSkinningData          = rifleModel.Tag as SkinningData;
            if (rifleSkinningData == null)
            {
                throw new InvalidOperationException
                          ("This model does not contain a SkinningData tag. Har du satt SkinnedModelProcessor? ");
            }

            clipPlayer = new ClipPlayer(rifleSkinningData, fps);
            rifleClip  = rifleSkinningData.AnimationClips["Take 001"];

            shadowEffect = Content.Load <Effect>("Effects/ShadowEffect");
        }
Example #8
0
		public override void UnloadContent()
		{
			base.UnloadContent();

			ClipPlayer.UnloadContent();
			BoundingBoxRenderer.UnloadContent();
		}
        public void Play()
        {
            ClipPlayer player = soundInfo.Cached ? new CachedClipPlayer(soundInfo) as ClipPlayer : new LiveClipPlayer(soundInfo) as ClipPlayer;

            player.HasEnded += Player_HasEnded;
            clipPlayers.Add(player);
            AudioHandler.Play(player);
        }
Example #10
0
 private void UpdateClip(int index)
 {
     if (updatePlayer)
     {
         ClipPlayer player = this.model.PlayClip(this.model.AnimationClip[index], animationSpeeds[index]);
         player.Looping = true;
         updatePlayer   = false;
     }
 }
Example #11
0
    public override void LoadContent()
    {
      base.LoadContent();

			if (!string.IsNullOrEmpty(AttachedPathingNodeName) && AttachedPathingNode == null)
				AttachedPathingNode = GameScreen.GetPath(AttachedPathingNodeName);

      // Check to see if this was pre-loaded
			if (string.IsNullOrEmpty(SpriteSheetFileName))
			{
				Actor original;

				if (ContentManager != null)
					original = ContentManager.Load<Actor>(AssetName);
				else
					original = GameScreen.Content.Load<Actor>(AssetName);

				if (original == null)
					throw new Exception("Error: Could not load the Actor!");

				Direction = original.Direction;
				DrawOrder = original.DrawOrder;
				UpdateOrder = original.UpdateOrder;
				Name = original.Name;
				PlayerIndex = original.PlayerIndex;
				Role = original.Role;
				Enabled = original.Enabled;
				Visible = original.Visible;
				SpriteSheetFileName = original.SpriteSheetFileName;

				ClipPlayer = new AnimationPlayer2D(Game)
				             	{
				             		AssetName = original.ClipPlayer.AssetName,
				             		Sequences = original.ClipPlayer.Sequences
				             	};
			}

			ClipPlayer.GameScreen = GameScreen;
			ClipPlayer.SetShaderParameters += OnSetShaderParams;
			ClipPlayer.AssetPath = AssetFolder;
    	ClipPlayer.AssetName = SpriteSheetFileName;
			ClipPlayer.Game = Game;
			ClipPlayer.GameScreen = GameScreen;
			ClipPlayer.SpriteBatch = SpriteBatch;
			ClipPlayer.ContentManager = ContentManager;
			ClipPlayer.Initialize();

      if (BoundingBoxRenderer == null)
      {
        BoundingBoxRenderer = new BoundingBoxRenderer(Game);
        BoundingBoxRenderer.GameScreen = GameScreen;
        BoundingBoxRenderer.SpriteBatch = SpriteBatch;
        BoundingBoxRenderer.Initialize();
      }
    }
Example #12
0
 public void Play()
 {
     if (playing)
     {
         Stop();
     }
     clipPlayer           = soundInfo.Cached ? new CachedClipPlayer(soundInfo) as ClipPlayer : new LiveClipPlayer(soundInfo) as ClipPlayer;
     clipPlayer.HasEnded += Player_HasEnded;
     AudioHandler.Play(clipPlayer);
     playing = true;
 }
Example #13
0
 void Start()
 {
     currentHealth   = totalHealth;
     cameraShaker    = FindObjectOfType <CameraFollow>();
     playAgainCanvas = FindObjectOfType <PlayAgain>();
     score           = FindObjectOfType <Score>();
     clipPlayer      = FindObjectOfType <ClipPlayer>();
     clipAudioSource = clipPlayer.GetComponent <AudioSource>();
     audioSource     = GetComponent <AudioSource>();
     playAgainCanvas.Hide();
 }
Example #14
0
 private void Awake()
 {
     if (Instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         Instance = this;
         DontDestroyOnLoad(gameObject);
     }
 }
Example #15
0
        public override void Reset()
        {
            playerType   = PlayerType.ClipPlayerUI;
            clipPlayer   = null;
            clipPlayerUI = null;

            actionType = ActionType.Play;

            clip       = null;
            startDelay = 0;
            loop       = true;
        }
Example #16
0
  	public override void Draw(GameTime gameTime)
    {
			if(!Visible || !Enabled)
				return;

      ClipPlayer.Draw(gameTime);

			if (BoundingBoxRenderer != null && ShowBoundingBox)
				BoundingBoxRenderer.Draw(gameTime);

  	  base.Draw(gameTime);
    }
Example #17
0
    public IEnumerator Idle()
    {
        currentStateName = "Idle";
        while (true)
        {
            yield return(null);

            player.PositionInMap = mapController.map.WorldToMapPoint(Position);
            if (!Application.isEditor || Application.isPlaying)
            {
                player.Update();
            }
            Vector2 direction = mapController.map.MapToWorldDirection(player.Forward);
            if (ClipPlayer != null && Time.timeScale > 0)
            {
                string clipName = "";
                if (direction.normalized.y > 0.8f)
                {
                    clipName = "Top";
                }
                else if (direction.normalized.y < -0.8f)
                {
                    clipName = "Down";
                }
                else if (direction.normalized.x > 0)
                {
                    clipName = "Right";
                }
                else
                {
                    clipName = "Left";
                }

                if (player.VelocityDir.magnitude > 0.1f)
                {
                    clipName += "Walk";
                }
                else
                {
                    clipName += "Stand";
                }
                ClipPlayer.PlayClip(clipName);
            }
            Position = mapController.map.MapToWorldPoint(player.PositionInMap);
        }
    }
Example #18
0
 public override void Load(int clipStart, int clipEnd, int fps)
 {
     skd = Model.Tag as SkinningData;
     clipPlayer = new ClipPlayer(skd, fps);//ClipPlayer running at 24 frames/sec
     AnimationClip clip = skd.AnimationClips["Take 001"]; //Take name from the dude.fbx file
     clipPlayer.play(clip, clipStart, clipEnd, false);
     modelScale = 0.4f;
     enemyMatrix = Matrix.CreateScale(modelScale) * Matrix.CreateRotationY((float)MathHelper.Pi * 2) *
                        Matrix.CreateTranslation(Position);
     BoundingSphere scaledSphere;
     scaledSphere = BoundingSphere;
     boundingSphereScale = 0.30f;
     scaledSphere.Radius *= boundingSphereScale;
     BoundingSphere =
         new BoundingSphere(scaledSphere.Center, scaledSphere.Radius);
     // Set up the parameters
     SetupShaderParameters(PoseidonGame.contentManager, Model);
 }
Example #19
0
 /// <summary>
 /// Event Listener for the Play Button on the main screen
 /// Toggles the video between play and pause
 /// </summary>
 private void PlayButton_Click(object sender, RoutedEventArgs e)
 {
     if (isPlaying)                                   //If the current flag is set to true
     {
         ClipPlayer.Pause();                          //pause the video
         isPlaying              = false;
         PlayButton.Visibility  = Visibility.Hidden;  //Hide the play button graphic
         PauseButton.Visibility = Visibility.Visible; //show the pause button graphic
     }
     else
     {
         ClipPlayer.Play();                                //play the video
         isPlaying              = true;
         ClipPlayer.Position    = TimeSpan.FromSeconds(0); //Reset the clip
         PlayButton.Visibility  = Visibility.Visible;      //Show the play button graphic
         PauseButton.Visibility = Visibility.Hidden;       //hide the pause button graphic
     }
 }
Example #20
0
        /// <summary>
        /// Load your graphics content.
        /// </summary>
        protected override void LoadContent()
        {
            // Load the model.
            currentModel = Content.Load <Model>("dude");

            // Look up our custom skinning information.
            SkinningData skinningData = currentModel.Tag as SkinningData;

            if (skinningData == null)
            {
                throw new InvalidOperationException
                          ("This model does not contain a SkinningData tag.");
            }

            // Create an clip player, and start decoding an animation clip at 24fps.
            //animationPlayer = new AnimationPlayer(skinningData);
            clipPlayer = new ClipPlayer(skinningData, 24);
        }
Example #21
0
        public OtherPlayer(float x, float y, float z, Int32 identity, Int16 mo, float xro, float yro)
        {
            model = mo;
            Console.WriteLine(mo);
            position.X = x;
            position.Y = y;
            position.Z = z;
            id         = identity;
            alive      = true;
            Console.WriteLine(mo.ToString());
            if (model == Constants.HAMPUS)
            {
                mod           = Globals.hampus;
                clipPlayer    = new ClipPlayer(Globals.hampusSkinningData, 60);
                animationClip = Globals.hampusSkinningData.AnimationClips["Take 001"];
            }
            else if (model == Constants.RASMUS)
            {
                mod           = Globals.rasmus;
                clipPlayer    = new ClipPlayer(Globals.rasmusSkinningData, 60);
                animationClip = Globals.rasmusSkinningData.AnimationClips["Take 001"];
            }
            else if (model == Constants.VALTER)
            {
                mod           = Globals.valter;
                clipPlayer    = new ClipPlayer(Globals.valterSkinningData, 60);
                animationClip = Globals.valterSkinningData.AnimationClips["Take 001"];
            }
            else if (model == Constants.AXEL)
            {
                mod           = Globals.axel;
                clipPlayer    = new ClipPlayer(Globals.axelSkinningData, 60);
                animationClip = Globals.axelSkinningData.AnimationClips["Take 001"];
            }

            Globals.s += identity;

            xr = xro;
            yr = yro;
            Globals.players[identity] = this;

            //idle
            clipPlayer.play(animationClip, 570, 600, true);
        }
        private void OnSceneEvent(Enums.SceneState state)
        {
            if (ClipPlayer.CurrentSequence != null)
            {
                switch (state)
                {
                case Enums.SceneState.Playing:
                    ClipPlayer.Play(ClipPlayer.CurrentSequence.Name, ClipPlayer.IsLooped);
                    break;

                case Enums.SceneState.Stopped:
                {
                    CurrentPathLerpPosition = StartPathingLerpPosition;
                    CurrentPathNodeIndex    = StartPathNodeIndex;

                    ClipPlayer.Stop(true);
                }
                break;
                }
            }
        }
Example #23
0
        /// <summary>
        /// Event Listener that fires when the file drop down changes
        /// </summary>
        private void ClipDropDown_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (ClipDropDown.SelectedIndex != -1)                                                                  //as long as your not on a null selection
            {
                string text = ClipDropDown.SelectedItem.ToString();                                                //store the selected item out to a string

                foreach (FileElement info in fileList)                                                             //check through all the files
                {
                    if (info.Title.Equals(text))                                                                   //If you find one that matches
                    {
                        ClipDes.Text = info.Description;                                                           //set the main page description to the selected items description

                        ClipPlayer.Source = new Uri(ClipFolder + "/" + info.FileName, UriKind.RelativeOrAbsolute); //set the source of the media player to the selected item

                        ClipPlayer.Play();                                                                         //play the video clip
                        ClipPlayer.ScrubbingEnabled = true;                                                        //allow scrubbing
                        ClipPlayer.Position         = TimeSpan.FromSeconds(2);                                     //move the video forward two seconds. This allows for a really basic thumbnail
                        ClipPlayer.Pause();                                                                        //pause the video
                    }
                }
            }
        }
 void Start()
 {
     _clip = AudioStorage.instance.rebound;
     _audio = GetComponent<ClipPlayer>();
 }
Example #25
0
 public void Play(string sequence, bool loop)
 {
 	ClipPlayer.Play(sequence, loop);
 }
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (Globals.IsScenePaused)
            {
                return;
            }

            CameraOffsetX    = Globals.CurrentCameraOffsetX;
            CameraOffsetY    = Globals.CurrentCameraOffsetY;
            CameraZoomOffset = Globals.CurrentCameraZoom;

            float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds * 0.15f;

            if (ClipPlayer.CurrentSequence != null)
            {
                if (BoundingBoxRenderer != null)
                {
                    if (RenderWindow.FollowingObject == this)
                    {
                        BoundingBoxRenderer.Color = Color.Green;
                    }
                    else
                    {
                        BoundingBoxRenderer.Color = Color.Yellow;
                    }
                }

                if (AttachedPathingNode != null)
                {
                    // We are attached to a path check for nodes in the path
                    if (AttachedPathingNode.Nodes.Count > 0)
                    {
                        ClipPlayer.SpriteEffects = AttachedPathingNode.Nodes[CurrentPathNodeIndex].SpriteEffect;

                        // Update our draw order to be the same as the current node we are on
                        DrawOrder = AttachedPathingNode.Nodes[CurrentPathNodeIndex].DrawOrder;

                        // See if we should alter our animation sequence
                        if (AttachedPathingNode.Nodes[CurrentPathNodeIndex].AnimationSequence != null && !Globals.IsScenePaused && !Globals.IsSceneStopped)
                        {
                            // Update our Clip Player
                            ClipPlayer.Play(AttachedPathingNode.Nodes[CurrentPathNodeIndex].AnimationSequence.Name,
                                            AttachedPathingNode.Nodes[CurrentPathNodeIndex].IsLooped);
                        }

                        if (CurrentPathNodeIndex <= (AttachedPathingNode.Nodes.Count - 1))
                        {
                            if (AttachedPathingNode.IsTraveling && !Globals.IsScenePaused)
                            {
                                // Lerp to our next node
                                CurrentPathLerpPosition += (AttachedPathingNode.Nodes[CurrentPathNodeIndex].TravelSpeed * elapsed);
                            }

                            if (CurrentPathLerpPosition >= 1)
                            {
                                if (IsLerpingBackToFirstNode)
                                {
                                    CurrentPathNodeIndex--;
                                    CurrentPathLerpPosition = 0;
                                }
                                else
                                {
                                    if (CurrentPathNodeIndex < (AttachedPathingNode.Nodes.Count - 1))
                                    {
                                        CurrentPathNodeIndex++;
                                        CurrentPathLerpPosition = 0;
                                    }
                                }
                            }

                            // Check to see we are on the last node in the chain
                            if (CurrentPathNodeIndex == (AttachedPathingNode.Nodes.Count - 1) && !IsLerpingBackToFirstNode)
                            {
                                // we want to respawn back to the first so reset everything
                                if (AttachedPathingNode.LedgeTavelAlgo == LedgeTravelAlgo.RespawnAtFirstNode)
                                {
                                    // Reset to the begining pathing node
                                    CurrentPathNodeIndex = 0;

                                    // Reset our Lerp
                                    CurrentPathLerpPosition = 0;
                                }
                                else if (AttachedPathingNode.LedgeTavelAlgo == LedgeTravelAlgo.LerpToFirstNode)
                                {
                                    // Flag we are lerping back to the last node
                                    IsLerpingBackToFirstNode = true;
                                    CurrentPathLerpPosition  = 0;
                                }
                                else if (AttachedPathingNode.LedgeTavelAlgo == LedgeTravelAlgo.StopAtLastNode)
                                {
                                    AttachedPathingNode.IsTraveling = false;
                                    CurrentPathLerpPosition         = 0;
                                }
                            }
                            else if (CurrentPathNodeIndex == 0 && IsLerpingBackToFirstNode)
                            {
                                IsLerpingBackToFirstNode = false;
                                CurrentPathLerpPosition  = 0;
                            }
                            else
                            {
                                // Continue to move along the path
                                if (IsLerpingBackToFirstNode)
                                {
                                    // Lerping Rotation Calculation ** value1 + (value2 - value1) * amount **
                                    float n1 = AttachedPathingNode.Nodes[CurrentPathNodeIndex - 1].Rotation;
                                    float n2 = AttachedPathingNode.Nodes[CurrentPathNodeIndex].Rotation;
                                    Rotation = n1 + (n2 - n1) * CurrentPathLerpPosition;

                                    // Moving Back towards the last node
                                    Position = Vector2.Lerp(AttachedPathingNode.Nodes[CurrentPathNodeIndex].Position,
                                                            AttachedPathingNode.Nodes[CurrentPathNodeIndex - 1].Position, CurrentPathLerpPosition);

                                    // Scaling
                                    Scale = Vector2.Lerp(AttachedPathingNode.Nodes[CurrentPathNodeIndex].Scale,
                                                         AttachedPathingNode.Nodes[CurrentPathNodeIndex - 1].Scale, CurrentPathLerpPosition);
                                }
                                else
                                {
                                    // Lerping Rotation Calculation ** value1 + (value2 - value1) * amount **
                                    float n1 = AttachedPathingNode.Nodes[CurrentPathNodeIndex].Rotation;
                                    float n2 = AttachedPathingNode.Nodes[CurrentPathNodeIndex + 1].Rotation;
                                    Rotation = n1 + (n2 - n1) * CurrentPathLerpPosition;


                                    // Moving
                                    Position = Vector2.Lerp(AttachedPathingNode.Nodes[CurrentPathNodeIndex].Position,
                                                            AttachedPathingNode.Nodes[CurrentPathNodeIndex + 1].Position, CurrentPathLerpPosition);

                                    // Scaling
                                    Scale = Vector2.Lerp(AttachedPathingNode.Nodes[CurrentPathNodeIndex].Scale,
                                                         AttachedPathingNode.Nodes[CurrentPathNodeIndex + 1].Scale, CurrentPathLerpPosition);
                                }
                            }
                        }
                    }
                }

                if (IsSelected)
                {
                    if (AttachedPathingNode != null)
                    {
                        AttachedPathingNode.IsSelected = true;
                        foreach (var n in AttachedPathingNode.Nodes)
                        {
                            n.IsSelected = true;
                        }
                    }

                    ShowBoundingBox = true;
                }
                else
                {
                    if (AttachedPathingNode != null)
                    {
                        AttachedPathingNode.IsSelected = false;
                        foreach (var n in AttachedPathingNode.Nodes)
                        {
                            n.IsSelected = false;
                        }
                    }

                    ShowBoundingBox = false;
                }
            }
        }
Example #27
0
 public void Stop(bool reset)
 {
 	ClipPlayer.Stop(reset);
 }
Example #28
0
File: Fish.cs Project: khoatle/game
        public void Load(int clipStart, int clipEnd, int fpsRate)
        {
            skd = Model.Tag as SkinningData;
            clipPlayer = new ClipPlayer(skd, fpsRate);//ClipPlayer running at 24 frames/sec
            AnimationClip clip = skd.AnimationClips["Take 001"]; //Take name from the dude.fbx file
            clipPlayer.play(clip, clipStart, clipEnd, true);
            fishMatrix = Matrix.CreateScale(1.0f) * Matrix.CreateRotationY((float)MathHelper.Pi * 2) *
                               Matrix.CreateTranslation(Position);
            BoundingSphere scaledSphere;
            scaledSphere = BoundingSphere;

            float scale = 1.0f;
            if (Name.Contains("turtle")) scale = 0.4f;
            if (Name.Contains("dolphin")) scale = 0.25f;
            if (Name.Contains("manetee")) scale = 0.4f;
            if (Name.Contains("sting ray")) scale = 0.5f;
            if (Name.Contains("orca")) scale = 0.5f;
            if (Name.Contains("seal")) scale = 0.5f;
            if (Name.Contains("shark")) scale = 0.5f;
            if (Name.Contains("Maui")) scale = 0.5f;
            if (Name.Contains("Meiolania")) scale = 0.5f;
            if (Name.Contains("penguin")) scale = 2.0f;
            if (isBigBoss)
            {
                //scale *= 2.0f;
                maxHealth = 5000;
                health = 5000;
            }
            scaledSphere.Radius *= scale;

            BoundingSphere =
                new BoundingSphere(scaledSphere.Center, scaledSphere.Radius);

            // Set up the parameters
            SetupShaderParameters(PoseidonGame.contentManager, Model);
            EffectHelpers.GetEffectConfiguration(ref fogColor, ref ambientColor, ref diffuseColor, ref specularColor);
        }
Example #29
0
        //public BoundingBox boundingBox;
        public void LoadContent(ContentManager content, string modelname, bool isAnimated, int clipStart, int clipEnd, int fpsRate)
        {
            if (HydroBot.gameMode == GameMode.MainGame)
            {
                orientation = (float)random.Next(0, 629) / 100;
                if (!isAnimated)
                    modelScale = (float)random.Next(5, 11) / 10;
                else modelScale = random.Next(4, 7);
            }
            else if (HydroBot.gameMode == GameMode.ShipWreck)
            {
                modelScale = 1.0f;
            }
            Model = content.Load<Model>(modelname);
            Position = Vector3.Down;
            BoundingSphere = CalculateBoundingSphere();

            BoundingSphere scaledSphere;
            scaledSphere = BoundingSphere;

            boundingSphereScale = modelScale;
            if (HydroBot.gameMode == GameMode.ShipWreck)
                scaledSphere.Radius *= GameConstants.ShipWreckBoundingSphereFactor;
            else scaledSphere.Radius *= boundingSphereScale;
            BoundingSphere =
                new BoundingSphere(scaledSphere.Center, scaledSphere.Radius);

            this.isAnimated = isAnimated;

            if (isAnimated)
            {
                skd = Model.Tag as SkinningData;
                clipPlayer = new ClipPlayer(skd, fpsRate);//ClipPlayer running at 24 frames/sec
                AnimationClip clip = skd.AnimationClips["Take 001"]; //Take name from the dude.fbx file
                clipPlayer.play(clip, clipStart, clipEnd, true);
                fishMatrix = Matrix.CreateScale(modelScale) * Matrix.CreateRotationY((float)MathHelper.Pi * 2) *
                                   Matrix.CreateTranslation(Position);
            }

            // Set up the parameters
            //SetupShaderParameters(content, Model);
        }
Example #30
0
 void Start()
 {
     clipPlayer = GetComponent<ClipPlayer> ();
     distanceTracker = GetComponent<DistanceTracker> ();
     goalSpawner = GetComponent<GoalSpawner> ();
 }
Example #31
0
		public override void Update(GameTime gameTime)
		{
			base.Update(gameTime);

			if (!Enabled)
				return;

			float elapsed = (float) gameTime.ElapsedGameTime.TotalSeconds*0.33f;

			switch (Direction)
			{
				case Direction.Left:
					ClipPlayer.IsFlipped = true;
					break;
				case Direction.Right:
					ClipPlayer.IsFlipped = false;
					break;
			}

			if (ClipPlayer.Texture != null && ClipPlayer.CurrentSequence != null && ClipPlayer.CurrentSequence.Frames.Count > 0)
			{
				#region Pathing Nodes

				if (AttachedPathingNode != null)
				{
					// We are attached to a path check for nodes in the path
					if (AttachedPathingNode.Nodes.Count > 0)
					{
						SpriteEffects = AttachedPathingNode.Nodes[CurrentPathNodeIndex].SpriteEffect;

						// Update our draw order to be the same as the current node we are on
						if (AttachedPathingNode.UseNodesDrawOrder)
							DrawOrder = AttachedPathingNode.Nodes[CurrentPathNodeIndex].DrawOrder;

						// See if we should alter our animation sequence
						if (AttachedPathingNode.Nodes[CurrentPathNodeIndex].AnimationSequence != null && CurrentPathLerpPosition == 0)
						{
							// Update our Clip Player
							ClipPlayer.Play(AttachedPathingNode.Nodes[CurrentPathNodeIndex].AnimationSequence.Name,
							                AttachedPathingNode.Nodes[CurrentPathNodeIndex].IsLooped);
						}

						if (CurrentPathNodeIndex <= (AttachedPathingNode.Nodes.Count - 1))
						{
							if (AttachedPathingNode.IsTraveling)
							{
								// Lerp to our next node
								CurrentPathLerpPosition += (AttachedPathingNode.Nodes[CurrentPathNodeIndex].TravelSpeed*elapsed);
							}

							if (CurrentPathLerpPosition >= 1)
							{
								if (IsLerpingBackToFirstNode)
								{
									CurrentPathNodeIndex--;
									CurrentPathLerpPosition = 0;
								}
								else
								{
									if (CurrentPathNodeIndex < (AttachedPathingNode.Nodes.Count - 1))
									{
										CurrentPathNodeIndex++;
										CurrentPathLerpPosition = 0;
									}
								}
							}

							// Check to see we are on the last node in the chain
							if (CurrentPathNodeIndex == (AttachedPathingNode.Nodes.Count - 1) && !IsLerpingBackToFirstNode)
							{
                // we want to respawn back to the first so reset everything
                switch (AttachedPathingNode.LedgeTavelAlgo)
                {
                  case LedgeTravelAlgo.RespawnAtFirstNode:
                    if (AttachedPathingNode.Nodes[CurrentPathNodeIndex].RespawnDelay > TimeSpan.Zero)
                    {
                      if (AttachedPathingNode.Nodes[CurrentPathNodeIndex].NodeElapsedTime >
                          AttachedPathingNode.Nodes[CurrentPathNodeIndex].RespawnDelay)
                      {
                        // purge the last node elapsed time
                        AttachedPathingNode.Nodes[CurrentPathNodeIndex].NodeElapsedTime = TimeSpan.Zero;

                        // Reset to the begining pathing node
                        CurrentPathNodeIndex = 0;

                        // Reset our Lerp
                        CurrentPathLerpPosition = 0;
                      }
                      else
                      {
                        AttachedPathingNode.Nodes[CurrentPathNodeIndex].NodeElapsedTime += gameTime.ElapsedGameTime;
                      }
                    }
                    else
                    {
                      // Reset to the begining pathing node
                      CurrentPathNodeIndex = 0;

                      // Reset our Lerp
                      CurrentPathLerpPosition = 0;
                    }
                    break;
                  case LedgeTravelAlgo.LerpToFirstNode:
                    IsLerpingBackToFirstNode = true;
                    CurrentPathLerpPosition = 0;
                    break;
                  case LedgeTravelAlgo.StopAtLastNode:
                    AttachedPathingNode.IsTraveling = false;
                    CurrentPathLerpPosition = 0;
                    break;
                }
							}
							else if (CurrentPathNodeIndex == 0 && IsLerpingBackToFirstNode)
							{
								IsLerpingBackToFirstNode = false;
								CurrentPathLerpPosition = 0;
							}
							else
							{
								// Continue to move along the path
								if (IsLerpingBackToFirstNode)
								{
									// Lerping Rotation Calculation ** value1 + (value2 - value1) * amount **
									float n1 = AttachedPathingNode.Nodes[CurrentPathNodeIndex - 1].Rotation;
									float n2 = AttachedPathingNode.Nodes[CurrentPathNodeIndex].Rotation;
									Rotation = n1 + (n2 - n1) * CurrentPathLerpPosition;

									// Moving Back towards the last node
									Position = Vector2.Lerp(AttachedPathingNode.Nodes[CurrentPathNodeIndex].Position,
									                        AttachedPathingNode.Nodes[CurrentPathNodeIndex - 1].Position, CurrentPathLerpPosition);

									// Scaling
									Scale = Vector2.Lerp(AttachedPathingNode.Nodes[CurrentPathNodeIndex].Scale,
									                     AttachedPathingNode.Nodes[CurrentPathNodeIndex - 1].Scale, CurrentPathLerpPosition);
								}
								else
								{
									// Lerping Rotation Calculation ** value1 + (value2 - value1) * amount **
									float n1 = AttachedPathingNode.Nodes[CurrentPathNodeIndex].Rotation;
									float n2 = AttachedPathingNode.Nodes[CurrentPathNodeIndex + 1].Rotation;
									Rotation = n1 + (n2 - n1) * CurrentPathLerpPosition;

									// Moving
									Position = Vector2.Lerp(AttachedPathingNode.Nodes[CurrentPathNodeIndex].Position,
									                        AttachedPathingNode.Nodes[CurrentPathNodeIndex + 1].Position, CurrentPathLerpPosition);

									// Scaling
									Scale = Vector2.Lerp(AttachedPathingNode.Nodes[CurrentPathNodeIndex].Scale,
									                     AttachedPathingNode.Nodes[CurrentPathNodeIndex + 1].Scale, CurrentPathLerpPosition);
								}
							}
						}
					}
				}

				#endregion

				// Incase it walks past the max frame count on the sequences
				if (ClipPlayer.CurrentFrameIndex >= ClipPlayer.CurrentSequence.Frames.Count)
				{
					if (ClipPlayer.IsLooped)
						ClipPlayer.CurrentFrameIndex = 0;
					else
						ClipPlayer.CurrentFrameIndex = ClipPlayer.CurrentSequence.Frames.Count - 1;
				}

				float tw = (ClipPlayer.CurrentSequence.Frames[ClipPlayer.CurrentFrameIndex].SourceRectangle.Width +
				            BoundingBoxScale.X)*Scale.X;

				float th = (ClipPlayer.CurrentSequence.Frames[ClipPlayer.CurrentFrameIndex].SourceRectangle.Height +
				            BoundingBoxScale.Y)*Scale.Y;

				if (IsCentered)
				{
					// Center Aligned means the position is actually in the center of the actor and needs to remove that
					float widthHalf = tw/2;
					float heightHalf = th/2;

					float posX1 = Position.X - widthHalf;
					float posY1 = Position.Y - heightHalf;

					float posX2 = Position.X + widthHalf;
					float posY2 = Position.Y + heightHalf;

					// Update our Bounding Box
					Vector3[] points = new Vector3[2];

					points[0] = new Vector3(posX1 + CameraOffsetX,
					                        posY1 + CameraOffsetY, -5);

					points[1] = new Vector3(posX2 + CameraOffsetX,
					                        posY2 + CameraOffsetY, 5);

					BoundingBox = BoundingBox.CreateFromPoints(points);
				}
				else
				{
					// Update our Bounding Box
					Vector3[] points = new Vector3[2];

					points[0] = new Vector3(Position.X + CameraOffsetX,
					                        Position.Y + CameraOffsetY, -5);

					points[1] = new Vector3(Position.X + CameraOffsetX + tw,
					                        Position.Y + CameraOffsetY + th, 5);

					// Create our Bounding Box
					BoundingBox = BoundingBox.CreateFromPoints(points);
				}

        if (BoundingBoxRenderer != null)
        {
          BoundingBoxRenderer.ShowBoundingBox = ShowBoundingBox;
          BoundingBoxRenderer.BoundingBox = BoundingBox;
          BoundingBoxRenderer.Update(gameTime);
        }

			  // Update our Clip Player
				ClipPlayer.IsCentered = IsCentered;
				ClipPlayer.Position = Position;
				ClipPlayer.Velocity = Velocity;
				ClipPlayer.Scale = Scale;
				ClipPlayer.Rotation = Rotation;
				ClipPlayer.SpriteEffects = SpriteEffects;
				ClipPlayer.CameraOffsetX = CameraOffsetX;
				ClipPlayer.CameraOffsetY = CameraOffsetY;
				ClipPlayer.CameraZoomOffset = CameraZoomOffset;
				ClipPlayer.BoundingBox = BoundingBox;
			  ClipPlayer.ShowBoundingBox = ShowBoundingBox;
				ClipPlayer.Update(gameTime);
			}
		}
 void Start()
 {
     _transform = GetComponent<Transform>();
     _rigidbody = GetComponent<Rigidbody>();
     _audio     = GetComponent<ClipPlayer>();
 }
 void Start()
 {
     UIManager.instance.ShowStartPanel();
     _audio = GetComponent<ClipPlayer>();
     AchievementSystem.AchievementManager.instance.achievementUnlockedAction += PlayAchievementClip;
 }
Example #34
0
        public virtual void Load(int clipStart, int clipEnd, int fps)
        {
            skd = Model.Tag as SkinningData;
            clipPlayer = new ClipPlayer(skd, fps);//ClipPlayer running at 24 frames/sec
            AnimationClip clip = skd.AnimationClips["Take 001"]; //Take name from the dude.fbx file
            clipPlayer.play(clip, clipStart, clipEnd, true);
            enemyMatrix = Matrix.CreateScale(0.1f) * Matrix.CreateRotationY((float)MathHelper.Pi * 2) *
                               Matrix.CreateTranslation(Position);
            BoundingSphere scaledSphere;
            scaledSphere = BoundingSphere;
            float scale = 1.0f;
            if (Name.Contains("Shooting Enemy")) scale = 0.05f;
            if (Name.Contains("Combat Enemy")) scale = 0.06f;
            scaledSphere.Radius *= scale;
            BoundingSphere =
                new BoundingSphere(scaledSphere.Center, scaledSphere.Radius);
            //isBigBoss = true;
            //random = new Random();
            //health = 1000;
            //maxHealth = 1000;
            //perceptionRadius = GameConstants.BossPerceptionRadius;
            //experienceReward = 400; //3000

            // Set up the parameters
            SetupShaderParameters(PoseidonGame.contentManager, Model);
        }