Exemplo n.º 1
0
    public GUIButtonAlpha(string _texture, float?leftPos, float?topPos, float?rightPos, float?botPos, float widthInPixels, float heightInPixels, float _layer = 0, bool _useScale = false) : base(false)
    {
        gameObject = GamePullController.CreateButtonAlpha();
        animation  = new ObjectAnimation(gameObject);

        layer    = _layer;
        useScale = _useScale;

        textureName  = _texture;
        sizeInPixels = new Vector2(widthInPixels, heightInPixels);

        if (leftPos != null)
        {
            left = leftPos;
        }
        if (topPos != null)
        {
            top = topPos;
        }

        if (rightPos != null)
        {
            right = rightPos;
        }

        if (botPos != null)
        {
            bottom = botPos;
        }

        isClickable = true;

        GUIController.Add(gameObject, this);
    }
Exemplo n.º 2
0
    public void Animate(MainJsonObject obj)
    {
        SendMessageJson jsonObj = new SendMessageJson();

        jsonObj.action = obj.action;
        jsonObj.msgId  = obj.msgId;
        string message = JsonConvert.SerializeObject(jsonObj);

        NetworkManager.Instance.Send(message);

        float   dt    = obj.contentObj.dt;
        JObject token = JObject.Parse(JObject.Parse(obj.content)["frames"].ToString());

        foreach (string key in token.Properties().Select(p => p.Name).ToList())
        {
            List <List <float> > array     = JArray.Parse(token[key].ToString()).ToObject <List <List <float> > >();
            List <Vector3>       positions = new List <Vector3>();
            List <Vector3>       rotations = new List <Vector3>();
            foreach (List <float> frame in array)
            {
                positions.Add(new Vector3(frame[0], frame[1], frame[2]));
                rotations.Add(new Vector3(frame[3], frame[4], frame[5]));
            }
            ObjectAnimation animation = new ObjectAnimation(dt, positions, rotations);
            AnimationManager.Instance.AddAnimation(objects[int.Parse(key)], animation);
        }
    }
Exemplo n.º 3
0
        public void SendAnimations()
        {
            ObjectGroup grp = m_Part.ObjectGroup;

            if (grp == null)
            {
                return;
            }
            SceneInterface scene = grp.Scene;

            if (scene == null)
            {
                return;
            }

            if ((m_Part.ExtendedMesh.Flags & ExtendedMeshParams.MeshFlags.AnimatedMeshEnabled) == 0)
            {
                return;
            }

            ObjectAnimation m = GetMessage();

            foreach (IAgent agent in scene.Agents)
            {
                agent.SendMessageAlways(m, scene.ID);
            }
            m_Part.TriggerOnUpdate(UpdateChangedFlags.None);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Constructor of the <c>NewGameScreen</c> class.
        /// </summary>
        /// <param name="name">Name of the screen.</param>
        /// <param name="menuEntriesSeparation">Separation between the menu entries.</param>
        public NewGameScreen(string name, int menuEntriesSeparation)
        {
            GameGraphicsDevice = EngineManager.GameGraphicsDevice;

            Name = name;

            TransitionOnTime  = TimeSpan.FromSeconds(0.5f);
            TransitionOffTime = TimeSpan.FromSeconds(0.5f);

            _menuEntriesSeparation = menuEntriesSeparation;
            _menuEntrySize         = ScreenManager.FontEntries.MeasureString("Example");
            _initialPosition       = new Vector2(50f, (GameSettings.DefaultInstance.ResolutionHeight / 2) -
                                                 (((_menuEntrySize.Y * 2) + TextureManager.GetTexture("EasyDifficult").BaseTexture.Height +
                                                   (_menuEntriesSeparation * 2)) / 2));
            _currentPosition = _initialPosition;

            _selectedEnd       = false;
            _selectedDifficult = 0;
            _selectedOption    = false;

            _model = new DrawableModel((GameModel)ModelManager.GetModel("AnimatedMonster"),
                                       new Vector3(12.5f, 10, 0), new Vector3(0, MathHelper.ToRadians(180), 0), Vector3.One * 10f, 0);

            _animation = new ObjectAnimation(Vector3.Zero, Vector3.Zero,
                                             _model.Rotation, _model.Rotation + new Vector3(MathHelper.TwoPi, 0, 0),
                                             TimeSpan.FromSeconds(5f), true);
        }
    public void InitObjectAnimation()
    {
        Debug.Log("marker: " + EventModelReference.Name);
        ObjectAnimation oa = GameObject.Find("Popup").GetComponent <ObjectAnimation>();

        oa.FillContentWithEventModel(EventModelReference);
        oa.AnimateUsingAnimationCurveInternal();
    }
Exemplo n.º 6
0
    private void GetHitObject(ObjectPrefab objectPrefab, ObjectAnimation objectAnimation)
    {
        objectPrefab.IsActive = false;
        objectAnimation.StartAnimation();
        int id = objectPrefab.ID;

        OnClick?.Invoke(id);
    }
Exemplo n.º 7
0
        public Entity(int id) : base(id)
        {
            CurrentDirection = Direction.Down;
            Animation        = new ObjectAnimation();

            _astarPath = new Queue <Point>();
            PathFinder = new AStar();
            //_isPathFinding = false;
        }
Exemplo n.º 8
0
 /// <summary>
 /// Stops currently playing <see cref="Animation"/>
 /// </summary>
 public new void ResetCurrentAnimation()
 {
     IsAnimated = false;
     if (ObjectAnimation != null)
     {
         ObjectAnimation.CurrentFrame = 0;
         this.CurrentTexture          = new Texture(ObjectAnimation.GetFrame(ObjectAnimation.CurrentFrame), TextureLayout.Stretch);
     }
 }
Exemplo n.º 9
0
    public GUIButtonAlpha() : base(false)
    {
        gameObject = GamePullController.CreateButtonAlpha();
        animation  = new ObjectAnimation(gameObject);

        isClickable = true;

        GUIController.Add(gameObject, this);
    }
Exemplo n.º 10
0
 void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
         if (hit.collider != null && hit.collider.GetComponent <ObjectPrefab>() && hit.collider.GetComponent <ObjectAnimation>())
         {
             ObjectPrefab    objectPrefab    = hit.collider.GetComponent <ObjectPrefab>();
             ObjectAnimation objectAnimation = hit.collider.GetComponent <ObjectAnimation>();
             GetHitObject(objectPrefab, objectAnimation);
         }
     }
 }
Exemplo n.º 11
0
    public Bomb(Vector2 position)
    {
        gameObject = GamePullController.CreateImage();
        texture    = Resources.Load("Textures/UserInterface/Bomb") as Texture;

        animation = new ObjectAnimation(gameObject);
        animation.Load("Bomb");
        animation.Play(-2);

        size        = new Vector2(1, 1);
        mapPosition = position;
        layer       = 0.5f;

        BombsController.bombs.Add(this);
    }
Exemplo n.º 12
0
        private ObjectAnimation GetMessage()
        {
            var m = new ObjectAnimation
            {
                Sender = m_Part.ID
            };

            lock (m_Lock)
            {
                foreach (var ai in m_ActiveAnimations)
                {
                    m.AnimationList.Add(new ObjectAnimation.AnimationData(ai.AnimID, ai.AnimSeq));
                }
            }
            return(m);
        }
Exemplo n.º 13
0
    public void Destroy()
    {
        if (rootImage != null)
        {
            rootImage.Destroy();
        }

        GameController.unitsToDestroy.Add(this);
        GamePullController.DestroyImage(gameObject);
        objectAnimation.Destroy();
        GameController.unitsDictionary.Remove(gameObject);
        gameObject      = null;
        objectAnimation = null;
        healthBar       = null;
        shadow          = null;
    }
Exemplo n.º 14
0
        public void Pan(PanDirection dir, bool animate = false)
        {
            var direction = GetVectorForDirection(dir, animate);

            if (animate)
            {
                ValueAnimation panAnimation = new ValueAnimation();
                panAnimation.InterpolationMethod = InterpMethod.Linear;
                panAnimation.SetKeyFrame(0.0f, App.RootNode.Position);
                panAnimation.SetKeyFrame(0.3f, App.RootNode.Position + direction);

                ObjectAnimation mainNodeAnimation = new ObjectAnimation();
                mainNodeAnimation.AddAttributeAnimation("Position", panAnimation, WrapMode.Once, 1f);

                App.RootNode.ObjectAnimation = mainNodeAnimation;
            }
            else
            {
                App.RootNode.Position += direction;
            }
        }
Exemplo n.º 15
0
 internal void InternalUpdate()
 {
     //UpdateCollider();
     if (IsAnimated)
     {
         ObjectAnimation.CountedTicks++;
         if (ObjectAnimation.CountedTicks == ObjectAnimation.FrameTickTrigger)
         {
             ObjectAnimation.CountedTicks = 0;
             if (ObjectAnimation.CurrentFrame == ObjectAnimation.AnimationFramesCount - 1)
             {
                 ObjectAnimation.CurrentFrame = 0;
             }
             else
             {
                 ObjectAnimation.CurrentFrame++;
             }
         }
         this.CurrentTexture = new Texture(ObjectAnimation.GetFrame(ObjectAnimation.CurrentFrame), TextureLayout.Stretch);
     }
 }
Exemplo n.º 16
0
    public Tower(string _type, Colorable.TeamColor _color)
    {
        reloadTime = 0.6f;
        type       = _type;
        color      = _color;

        gameObject = GamePullController.CreateImage();
        animation  = new ObjectAnimation(gameObject);

        gameObject.name += "Tower";
        gameObject.GetComponent <BoxCollider> ().enabled = true;

        texture = Resources.Load("Textures/Towers/" + type + "Tower") as Texture;

        attackAnimaton     = type + "TowerAttack";
        attackAnimatonTime = 0.2f;

        try {
            damage      = BalanceSettings.damage [type];
            damageDelta = BalanceSettings.deltaDamage [type];
            attackRange = BalanceSettings.attackRange [type];
            attackSpeed = BalanceSettings.attackSpeed [type];
        } catch (Exception) {
            Debug.LogError("Wrong tower type: " + type);
        }

        layer = 6;
        size  = new Vector2(texture.width / 50f, texture.height / 50f) / 2f * Settings.FhdToHD;

        GameController.towers.Add(this);
        GameController.towersDictionary.Add(gameObject, this);

        buffs = new Dictionary <Buff, float> (GameController.buffs[color]);

        foreach (var buff in TowersSettings.Buffs(type))
        {
            buffs.Add((Buff)Enum.Parse(typeof(Buff), buff), 1);
        }
    }
Exemplo n.º 17
0
        public void Zoom(ZoomDirection dir, bool animate = false)
        {
            if (animate)
            {
                var factor = (dir == ZoomDirection.In) ? _zoomInFactor : _zoomOutFactor;

                ValueAnimation zoomAnimation = new ValueAnimation();
                zoomAnimation.InterpolationMethod = InterpMethod.Linear;
                zoomAnimation.SetKeyFrame(0.0f, App.Camera.Zoom);
                zoomAnimation.SetKeyFrame(0.3f, App.Camera.Zoom * factor);

                ObjectAnimation cameraAnimation = new ObjectAnimation();
                cameraAnimation.AddAttributeAnimation("Zoom", zoomAnimation, WrapMode.Once, 1f);

                App.Camera.ObjectAnimation = cameraAnimation;
            }
            else
            {
                var factor = (dir == ZoomDirection.In) ? _zoomInFactorSmall : _zoomOutFactorSmall;

                App.Camera.Zoom *= factor;
            }
        }
        /// <summary>
        /// Load and calculate all the necessary content of the game.
        /// </summary>
        public override void Load()
        {
            base.Load();

            // Set the camera
            CameraManager.AddCamera(CameraManager.DefaultCamera,
                                    new TargetCamera(new Vector3(0, 0, 70), new Vector3(0, 0, 0)));
            CameraManager.SetActiveCamera(CameraManager.DefaultCamera);

            // Create the post processing elements
            renderCapture = new RenderCapture();
            postProcessor = new GaussianBlur(10);//2f);

            // Load all needed textures
            TextureManager.AddTexture(backgroundTexture, new GameTexture("Content/Textures/MenuBackground", true));
            TextureManager.AddTexture("DeadBackground", new GameTexture("Content/Textures/DeadBackground", true));
            TextureManager.AddTexture("SeparationBar", new GameTexture("Content/Textures/SeparationBar", true));
            TextureManager.AddTexture("SelectedMenuEntry", new GameTexture("Content/Textures/SelectedMenuEntry", true));
            TextureManager.AddTexture("DummyTexture15T", new GameTexture("Content/Textures/DummyTexture15T", true));
            TextureManager.AddTexture("DummyTexture", new GameTexture("Content/Textures/DummyTexture", true));
            TextureManager.AddTexture("BarTexture", new GameTexture("Content/Textures/BarTexture", true));
            TextureManager.AddTexture("DialogBackground", new GameTexture("Content/Textures/DialogBackground", true));
            TextureManager.AddTexture("EasyDifficult", new GameTexture("Content/Textures/EasyDifficult", true));
            TextureManager.AddTexture("NormalDifficult", new GameTexture("Content/Textures/NormalDifficult", true));
            TextureManager.AddTexture("HardDifficult", new GameTexture("Content/Textures/HardDifficult", true));
            TextureManager.AddTexture("LoadingBackground", new GameTexture("Content/Textures/LoadingBackground", true));

            // Load all needed sounds
            SoundManager.AddSound("Menu", new GameSound("Content/Sounds/Menu", true));
            SoundManager.GetSound("Menu").Volume = GameSettings.DefaultInstance.MusicVolume;
            SoundManager.GetSound("Menu").Play(true, true);

            SoundManager.AddSound("MenuSelect", new GameSound("Content/Sounds/MenuSelect", true));
            SoundManager.GetSound("MenuSelect").Volume = GameSettings.DefaultInstance.SoundVolume;
            SoundManager.AddSound("MenuAccept", new GameSound("Content/Sounds/MenuAccept", true));
            SoundManager.GetSound("MenuAccept").Volume = GameSettings.DefaultInstance.SoundVolume;

            // Load all needed models
            ModelManager.AddModel(spacecraftModel, new GameModel("Content/Models/Spacecraft", true));
            ModelManager.AddModel("AnimatedMonster", new GameModel("Content/Models/AnimatedMonster", true));
            _model = new DrawableModel((GameModel)ModelManager.GetModel(spacecraftModel),
                                       new Vector3(-10, 20, 0), new Vector3(-45, 120, 0), new Vector3(1.25f, 1.25f, 1.25f), 0);

            // Fix the animation elements
            _animationRing1 = new ObjectAnimation(Vector3.Zero, Vector3.Zero,
                                                  _model.Rotation, _model.Rotation + new Vector3(0, MathHelper.TwoPi, 0),
                                                  TimeSpan.FromSeconds(1f), true);

            _animationRing2 = new ObjectAnimation(Vector3.Zero, Vector3.Zero,
                                                  _model.Rotation + new Vector3(0, MathHelper.Pi, 0),
                                                  _model.Rotation + new Vector3(0, MathHelper.TwoPi + MathHelper.Pi, 0),
                                                  TimeSpan.FromSeconds(1f), true);

            _individualTransformations.Add("polySurface26",
                                           Matrix.CreateScale(_animationRing1.Scale) *
                                           Matrix.CreateRotationX(_animationRing1.Rotation.X) *
                                           Matrix.CreateRotationY(_animationRing1.Rotation.Y) *
                                           Matrix.CreateRotationZ(_animationRing1.Rotation.Z) *
                                           Matrix.CreateTranslation(_animationRing1.Position));

            _individualTransformations.Add("polySurface27",
                                           Matrix.CreateScale(_animationRing2.Scale) *
                                           Matrix.CreateRotationX(_animationRing2.Rotation.X) *
                                           Matrix.CreateRotationY(_animationRing2.Rotation.Y) *
                                           Matrix.CreateRotationZ(_animationRing2.Rotation.Z) *
                                           Matrix.CreateTranslation(_animationRing2.Position));
        }
Exemplo n.º 19
0
 private void Awake()
 {
     dotIO        = GetComponent <DotIOHandler>();
     dotAnimation = GetComponentInChildren <ObjectAnimation>();
 }
Exemplo n.º 20
0
    public void LineAdject(float PointX)
    {
        theta = Mathf.LerpAngle(transform.eulerAngles.y, PointX * 150, Time.deltaTime * RotationSpeed);

        if (theta >= 45f && theta <= 180)
        {
            theta = 45f;
        }
        else if (theta >= 180 && theta <= 315)
        {
            theta = 315f;
        }


        transform.eulerAngles = new Vector3(0, theta, 0);

        if (transform.localEulerAngles.y > 180)
        {
            float ConvertY;
            ConvertY = transform.localEulerAngles.y - 360;
            rad      = ConvertY * Mathf.Deg2Rad;
        }
        else
        {
            rad = transform.localEulerAngles.y * Mathf.Deg2Rad;
        }
        if (PointX > 0)
        {
            direction = 1;
        }
        else if (PointX < 0)
        {
            direction = -1;
        }
        else if (PointX == 0)
        {
            direction = 0;
        }

        if (!FirstTouch)
        {
            FirstTouch = true;
            LineActive(true);
        }
        else
        {
            float a = 0;
            // if (castList.Count != 0)
            // {
            //     for (int i = 0; i < castList.Count; i++)
            //         castList[i].TerrifiedReset();
            // }
            castList = new List <ObjectAnimation>();
            for (int i = 0; i < 32; i++)
            {
                Vector3 LineObjPos = new Vector3((a * Mathf.Tan(rad) - (Mathf.Pow(rad, 2f)) * direction * f * (Mathf.Pow(a, 2f) / Mathf.Pow(Mathf.Cos(rad), 2))) * c, transform.position.y, transform.position.z + a);
                LineObjs[i].transform.position = LineObjPos;
                a += 0.5f;
                line.SetPosition(i, LineObjPos);
                RaycastHit hit;
                if (i != 31)
                {
                    // Debug.DrawRay(LineObjs[i].transform.position, LineObjs[i + 1].transform.position - LineObjs[i].transform.position, Color.red, 0.1f);
                    if (Physics.Raycast(LineObjs[i].transform.position, LineObjs[i + 1].transform.position - LineObjs[i].transform.position, out hit, 1f))
                    {
                        if (hit.collider.tag.Equals("Target"))
                        {
                            ObjectAnimation objectAnimation = hit.collider.GetComponent <ObjectAnimation>();
                            castList.Add(objectAnimation);
                            if (!objectAnimations.Contains(objectAnimation))
                            {
                                objectAnimations.Add(objectAnimation);
                                objectAnimation.Terrified();
                            }
                        }
                    }
                }
            }
            List <ObjectAnimation> Resetlist = objectAnimations.Except(castList).ToList();
            for (int i = 0; i < Resetlist.Count; i++)
            {
                Resetlist[i].TerrifiedReset();
                objectAnimations.Remove(Resetlist[i]);
            }
        }
    }
Exemplo n.º 21
0
 public void AddAnimation(MainObject obj, ObjectAnimation animation)
 {
     obj.SetAnimation(animation);
 }
Exemplo n.º 22
0
    void Awake()
    {
        FSM = new FiniteStateMachine <ObjectController>();

        objectAnimation = this.transform.GetChild(0).GetComponent <ObjectAnimation>();
    }
Exemplo n.º 23
0
    protected Unit(TeamColor _color, int _road)
    {
        gameObject      = GamePullController.CreateImage();
        gameObject.name = "Unit";

        shadow = GamePullController.CreateImage();
        shadow.GetComponent <Renderer> ().material.mainTexture = ResourcesController.Load("Textures/Shadow") as Texture;
        healthBar = new HealthBar();

        GameController.unitsDictionary.Add(gameObject, this);

        objectAnimation = new ObjectAnimation(gameObject);

        color = _color;

        roadIndex = 0;
        var     count = (color == TeamColor.Red?GameController.RoadRed.Count:GameController.RoadBlue.Count);
        Vector3 _targetPosition;

        if (color == TeamColor.Red)
        {
            if (_road == -1)
            {
                do
                {
                    roadNumber = Random.Range(0, count);
                } while (GameController.RoadRed[roadNumber].Count == 0);
            }
            else
            {
                roadNumber = _road;
            }


            _targetPosition = GameController.RoadRed[roadNumber][roadIndex];
        }
        else
        {
            if (_road == -1)
            {
                do
                {
                    roadNumber = Random.Range(0, count);
                } while (GameController.RoadBlue[roadNumber].Count == 0);
            }
            else
            {
                roadNumber = _road;
            }

            _targetPosition = new Vector3();
            try {
                _targetPosition = GameController.RoadBlue[roadNumber][roadIndex];
            } catch (System.Exception) {
                Debug.LogError(roadNumber + " " + roadIndex + "; " + GameController.RoadBlue.Count + " ");
            }
        }

        layer          = _targetPosition.z;
        targetPosition = GetTruePosition(_targetPosition);
        mapPosition    = targetPosition;
        isKilling      = false;
    }
Exemplo n.º 24
0
 public void SetAnimation(ObjectAnimation objectAnimation)
 {
     this.objectAnimation = objectAnimation;
     this.objectAnimation.Start();
 }
Exemplo n.º 25
0
 public static void Remove(ObjectAnimation objectAnimation)
 {
     animationsToRemove.Add(objectAnimation);
 }
 /// <summary>
 /// Add a new <c>ObjectAnimation</c> to the manager.
 /// </summary>
 /// <param name="animationName">Name of the animation.</param>
 /// <param name="newAnimation">Instance of the <c>ObjectAnimation</c>.</param>
 public static void AddAnimation(string animationName, ObjectAnimation newAnimation)
 {
     _animations.Add(animationName, newAnimation);
 }
Exemplo n.º 27
0
        void CreateScene()
        {
            var cache = ResourceCache;

            scene = new Scene();

            // Create the Octree component to the scene. This is required before adding any drawable components, or else nothing will
            // show up. The default octree volume will be from (-1000, -1000, -1000) to (1000, 1000, 1000) in world coordinates; it
            // is also legal to place objects outside the volume but their visibility can then not be checked in a hierarchically
            // optimizing manner
            scene.CreateComponent <Octree>();

            // Create a child scene node (at world origin) and a StaticModel component into it. Set the StaticModel to show a simple
            // plane mesh with a "stone" material. Note that naming the scene nodes is optional. Scale the scene node larger
            // (100 x 100 world units)
            Node planeNode = scene.CreateChild("Plane");

            planeNode.Scale = new Vector3(100.0f, 1.0f, 100.0f);
            StaticModel planeObject = planeNode.CreateComponent <StaticModel>();

            planeObject.Model = (cache.GetModel("Models/Plane.mdl"));
            planeObject.SetMaterial(cache.GetMaterial("Materials/StoneTiled.xml"));

            // Create a point light to the world so that we can see something.
            Node  lightNode = scene.CreateChild("PointLight");
            Light light     = lightNode.CreateComponent <Light>();

            light.LightType = LightType.Point;
            light.Range     = (10.0f);

            // Create light animation
            ObjectAnimation lightAnimation = new ObjectAnimation();

            // Create light position animation
            ValueAnimation positionAnimation = new ValueAnimation();

            // Use spline interpolation method
            positionAnimation.InterpolationMethod = InterpMethod.Spline;
            // Set spline tension
            positionAnimation.SplineTension = 0.7f;

            positionAnimation.SetKeyFrame(0.0f, new Vector3(-30.0f, 5.0f, -30.0f));
            positionAnimation.SetKeyFrame(1.0f, new Vector3(30.0f, 5.0f, -30.0f));
            positionAnimation.SetKeyFrame(2.0f, new Vector3(30.0f, 5.0f, 30.0f));
            positionAnimation.SetKeyFrame(3.0f, new Vector3(-30.0f, 5.0f, 30.0f));
            positionAnimation.SetKeyFrame(4.0f, new Vector3(-30.0f, 5.0f, -30.0f));
            // Set position animation
            lightAnimation.AddAttributeAnimation("Position", positionAnimation, WrapMode.Loop, 1f);

            // Create text animation
            ValueAnimation textAnimation = new ValueAnimation();

            textAnimation.SetKeyFrame(0.0f, "WHITE");
            textAnimation.SetKeyFrame(1.0f, "RED");
            textAnimation.SetKeyFrame(2.0f, "YELLOW");
            textAnimation.SetKeyFrame(3.0f, "GREEN");
            textAnimation.SetKeyFrame(4.0f, "WHITE");
            var uiElement = UI.Root.GetChild("animatingText", false);

            uiElement.SetAttributeAnimation("Text", textAnimation, WrapMode.Loop, 1f);

            // Create light color animation
            ValueAnimation colorAnimation = new ValueAnimation();

            colorAnimation.SetKeyFrame(0.0f, Color.White);
            colorAnimation.SetKeyFrame(1.0f, Color.Red);
            colorAnimation.SetKeyFrame(2.0f, Color.Yellow);
            colorAnimation.SetKeyFrame(3.0f, Color.Green);
            colorAnimation.SetKeyFrame(4.0f, Color.White);
            // Set Light component's color animation
            lightAnimation.AddAttributeAnimation("@Light/Color", colorAnimation, WrapMode.Loop, 1f);

            // Apply light animation to light node
            lightNode.ObjectAnimation = lightAnimation;

            // Create more StaticModel objects to the scene, randomly positioned, rotated and scaled. For rotation, we construct a
            // quaternion from Euler angles where the Y angle (rotation about the Y axis) is randomized. The mushroom model contains
            // LOD levels, so the StaticModel component will automatically select the LOD level according to the view distance (you'll
            // see the model get simpler as it moves further away). Finally, rendering a large number of the same object with the
            // same material allows instancing to be used, if the GPU supports it. This reduces the amount of CPU work in rendering the
            // scene.
            const uint numObjects = 200;

            for (uint i = 0; i < numObjects; ++i)
            {
                Node mushroomNode = scene.CreateChild("Mushroom");
                mushroomNode.Position = (new Vector3(NextRandom(90.0f) - 45.0f, 0.0f, NextRandom(90.0f) - 45.0f));
                mushroomNode.Rotation = new Quaternion(0.0f, NextRandom(360.0f), 0.0f);
                mushroomNode.SetScale(0.5f + NextRandom(2.0f));
                StaticModel mushroomObject = mushroomNode.CreateComponent <StaticModel>();
                mushroomObject.Model = (cache.GetModel("Models/Mushroom.mdl"));
                mushroomObject.SetMaterial(cache.GetMaterial("Materials/Mushroom.xml"));
            }

            // Create a scene node for the camera, which we will move around
            // The camera will use default settings (1000 far clip distance, 45 degrees FOV, set aspect ratio automatically)
            CameraNode = scene.CreateChild("Camera");
            CameraNode.CreateComponent <Camera>();

            // Set an initial position for the camera scene node above the plane
            CameraNode.Position = (new Vector3(0.0f, 5.0f, 0.0f));
        }
Exemplo n.º 28
0
 public void Add(UIControlState state, ObjectAnimation animation)
 {
     _visualStates
     .FindOrCreate(state, () => new List <ObjectAnimation>())
     .Add(animation);
 }
Exemplo n.º 29
0
		void CreateScene()
		{
			var cache = ResourceCache;

			scene = new Scene();

			// Create the Octree component to the scene. This is required before adding any drawable components, or else nothing will
			// show up. The default octree volume will be from (-1000, -1000, -1000) to (1000, 1000, 1000) in world coordinates; it
			// is also legal to place objects outside the volume but their visibility can then not be checked in a hierarchically
			// optimizing manner
			scene.CreateComponent<Octree>();

			// Create a child scene node (at world origin) and a StaticModel component into it. Set the StaticModel to show a simple
			// plane mesh with a "stone" material. Note that naming the scene nodes is optional. Scale the scene node larger
			// (100 x 100 world units)
			Node planeNode = scene.CreateChild("Plane");
			planeNode.Scale=new Vector3(100.0f, 1.0f, 100.0f);
			StaticModel planeObject = planeNode.CreateComponent<StaticModel>();
			planeObject.Model = (cache.GetModel("Models/Plane.mdl"));
			planeObject.SetMaterial(cache.GetMaterial("Materials/StoneTiled.xml"));

			// Create a point light to the world so that we can see something. 
			Node lightNode = scene.CreateChild("PointLight");
			Light light = lightNode.CreateComponent<Light>();
			light.LightType = LightType.Point;
			light.Range = (10.0f);

			// Create light animation
			ObjectAnimation lightAnimation=new ObjectAnimation();

			// Create light position animation
			ValueAnimation positionAnimation=new ValueAnimation();
			// Use spline interpolation method
			positionAnimation.InterpolationMethod= InterpMethod.Spline;
			// Set spline tension
			positionAnimation.SplineTension=0.7f;

			positionAnimation.SetKeyFrame(0.0f, new Vector3(-30.0f, 5.0f, -30.0f));
			positionAnimation.SetKeyFrame(1.0f, new Vector3(30.0f, 5.0f, -30.0f));
			positionAnimation.SetKeyFrame(2.0f, new Vector3(30.0f, 5.0f, 30.0f));
			positionAnimation.SetKeyFrame(3.0f, new Vector3(-30.0f, 5.0f, 30.0f));
			positionAnimation.SetKeyFrame(4.0f, new Vector3(-30.0f, 5.0f, -30.0f));
			// Set position animation
			lightAnimation.AddAttributeAnimation("Position", positionAnimation, WrapMode.Loop, 1f);

			// Create text animation
			ValueAnimation textAnimation=new ValueAnimation();
			textAnimation.SetKeyFrame(0.0f, "WHITE");
			textAnimation.SetKeyFrame(1.0f, "RED");
			textAnimation.SetKeyFrame(2.0f, "YELLOW");
			textAnimation.SetKeyFrame(3.0f, "GREEN");
			textAnimation.SetKeyFrame(4.0f, "WHITE");
			var uiElement = UI.Root.GetChild("animatingText", false);
			uiElement.SetAttributeAnimation("Text", textAnimation, WrapMode.Loop, 1f);

			// Create light color animation
			ValueAnimation colorAnimation=new ValueAnimation();
			colorAnimation.SetKeyFrame(0.0f, Color.White);
			colorAnimation.SetKeyFrame(1.0f, Color.Red);
			colorAnimation.SetKeyFrame(2.0f, Color.Yellow);
			colorAnimation.SetKeyFrame(3.0f, Color.Green);
			colorAnimation.SetKeyFrame(4.0f, Color.White);
			// Set Light component's color animation
			lightAnimation.AddAttributeAnimation("@Light/Color", colorAnimation, WrapMode.Loop, 1f);

			// Apply light animation to light node
			lightNode.ObjectAnimation=lightAnimation;

			// Create more StaticModel objects to the scene, randomly positioned, rotated and scaled. For rotation, we construct a
			// quaternion from Euler angles where the Y angle (rotation about the Y axis) is randomized. The mushroom model contains
			// LOD levels, so the StaticModel component will automatically select the LOD level according to the view distance (you'll
			// see the model get simpler as it moves further away). Finally, rendering a large number of the same object with the
			// same material allows instancing to be used, if the GPU supports it. This reduces the amount of CPU work in rendering the
			// scene.
			const uint numObjects = 200;
			for (uint i = 0; i < numObjects; ++i)
			{
				Node mushroomNode = scene.CreateChild("Mushroom");
				mushroomNode.Position = (new Vector3(NextRandom(90.0f) - 45.0f, 0.0f, NextRandom(90.0f) - 45.0f));
				mushroomNode.Rotation=new Quaternion(0.0f, NextRandom(360.0f), 0.0f);
				mushroomNode.SetScale(0.5f + NextRandom(2.0f));
				StaticModel mushroomObject = mushroomNode.CreateComponent<StaticModel>();
				mushroomObject.Model = (cache.GetModel("Models/Mushroom.mdl"));
				mushroomObject.SetMaterial(cache.GetMaterial("Materials/Mushroom.xml"));
			}

			// Create a scene node for the camera, which we will move around
			// The camera will use default settings (1000 far clip distance, 45 degrees FOV, set aspect ratio automatically)
			CameraNode = scene.CreateChild("Camera");
			CameraNode.CreateComponent<Camera>();

			// Set an initial position for the camera scene node above the plane
			CameraNode.Position = (new Vector3(0.0f, 5.0f, 0.0f));
		}
Exemplo n.º 30
0
 public static void Add(ObjectAnimation objectAnimation)
 {
     animations.Add(objectAnimation);
 }