Exemplo n.º 1
0
        public override void Update(UpdateState state)
        {
            switch (fightState)
            {
                case FightState.starting:
                    if(fadeTime == 1f)
                        fightWorld.Update(state);

                    fadeTime -= state.elapsedTime;
                    activeBox.texture.filter = Color.Lerp(Color.White, Color.Transparent, fadeTime);
                    if (fadeTime <= 0f)
                        fightState = FightState.fighting;

                    break;
                case FightState.fighting:
                    fightWorld.Update(state);
                    fightTime += state.elapsedTime;

                    if (fightTime >= 30f)
                    {
                        fightTime = 0f;
                        EndFight();
                    }
                    break;
            }
        }
Exemplo n.º 2
0
 public override void Update(UpdateState state)
 {
     if (anchor != null)
     {
         camera.position += (anchor.position - camera.position) * 3f * state.elapsedTime;
         this.position = camera.position;
     }
 }
Exemplo n.º 3
0
 public override void Update(UpdateState state)
 {
     if (textureLoaded)
     {
         texture.period = land.waterWavesTimePeriod;
         texture.Phase = land.waterWavesPhase;
     }
     base.Update(state);
 }
Exemplo n.º 4
0
 public override void Update(UpdateState state)
 {
     lock (textureContentLock)
     {
         if (textureContent != null)
         {
             assetTexture.setContent(textureContent);
             textureContent = null;
         }
     }
 }
Exemplo n.º 5
0
        public override void Update(UpdateState state)
        {
            KeyboardState keybState = Keyboard.GetState();

            ActionKeyType keyType;
            int keybLength = Enum.GetValues(typeof(ActionKeyType)).Length;
            for (int i = 0; i < keybLength; i++)
            {
                keyType = (ActionKeyType)i;
                keyboard.keyboard[keyType].Update(state.elapsedTime, keybState.IsKeyDown(keyMapping[keyType]));
            }

            base.Update(state);
        }
Exemplo n.º 6
0
        public virtual void Update(GameTime time, int GlobalUpdateID)
        {
            bool update = false;

            updatesPassed++;
            timeElapsedSinceLastUpdate = time.ElapsedGameTime.Milliseconds;

            switch (frequency)
            {
                case UpdateFrequency.One:
                    update = true;
                    break;
                case UpdateFrequency.OneHalf:
                    if (updatesPassed % 2 == 0)
                        update = true;
                    break;
                case UpdateFrequency.OneQuarter:
                    if (updatesPassed % 4 == 0)
                        update = true;
                    break;
                case UpdateFrequency.OneEigth:
                    if (updatesPassed % 8 == 0)
                        update = true;
                    break;
                case UpdateFrequency.OneSixteenth:
                    if (updatesPassed % 16 == 0)
                        update = true;
                    break;
            }

            if (update)
            {
                currentUpdateID++;

                UpdateState state = new UpdateState(((float)timeElapsedSinceLastUpdate)/1000f, GlobalUpdateID, currentUpdateID, this);

                updatedObject.Update(state);
                updatesPassed = 0;
                timeElapsedSinceLastUpdate = 0;
            }
        }
Exemplo n.º 7
0
        public virtual void Update(UpdateState state)
        {
            for (int i = 0; i < objectList.Count; i++)
            {
                objectList[i].Update(state);
            }

            //Remove objects awaiting removal
            while (objectRemoveList.Count != 0)
            {
                objectList.Remove(objectRemoveList[0]);
                objectRemoveList.RemoveAt(0);
            }

            //Add adicional objects
            while (objectAddList.Count != 0)
            {
                objectList.Add(objectAddList[0]);
                objectAddList.RemoveAt(0);
            }
        }
Exemplo n.º 8
0
        public override void Update(UpdateState state)
        {
            if (loadingLand.isBeingLoaded())
            {
                dots++;
                int dotNumber = (dots / 40) % 4;
                switch (dotNumber)
                {
                    case 0:
                        statusText.text = loadingLand.checkLoadStatus() + "";
                        break;
                    case 1:
                        statusText.text = " " + loadingLand.checkLoadStatus() + ".";
                        break;
                    case 2:
                        statusText.text = "  " + loadingLand.checkLoadStatus() + "..";
                        break;
                    case 3:
                        statusText.text = "   " + loadingLand.checkLoadStatus() + "...";
                        break;
                }

                barTime += state.elapsedTime;
                statusBar.position.X = 120f * (float)Math.Sin(barTime*Math.PI);
            }
            else if(loadingLand.isLoaded())
            {
                fade -= state.elapsedTime;

                if (fade < 0f)
                    fade = 0f;

                statusText.text = "Loaded";
                statusText.filter = Color.Lerp(Color.Transparent, Color.White, fade);
                statusBar.filter = Color.Lerp(Color.Transparent, Color.White, fade);

                if (fade == 0f)
                    destroy();
            }
        }
Exemplo n.º 9
0
        public override void Update(UpdateState state)
        {
            if (running)
            {
                currentTime += state.elapsedTime;

                float animationFactor = currentTime / lifetime;

                if (animationFactor > 1f)
                {
                    animationFactor = 1f;
                    ended           = true;
                    running         = false;
                }

                if (interpolPosition)
                {
                    target.position = originalPosition * (1f - animationFactor) + destinationPosition * animationFactor;
                }

                if (interpolRotation)
                {
                    target.rotation = originalRotation * (1f - animationFactor) + destinationRotation * animationFactor;
                }

                if (interpolSize)
                {
                    ((Resizable)target).setSize(originalSize * (1f - animationFactor) + destinationSize * animationFactor);
                }
            }
            else
            {
                if (ended)
                {
                    destroy();
                }
            }
        }
Exemplo n.º 10
0
        public static void checkIfRepeats(UpdateState state)
        {
            bool a;

            if (state.GlobalUpdateID != repID)
                repID = state.GlobalUpdateID;
            else
                a = true;
        }
Exemplo n.º 11
0
 public override void Update(UpdateState state)
 {
     texture.Phase += state.elapsedTime;
     base.Update(state);
 }
Exemplo n.º 12
0
 public override void Update(UpdateState state)
 {
 }
Exemplo n.º 13
0
 public virtual void Update(UpdateState state)
 {
     this.position += velocity;
     this.rotation += rotationSpeed;
 }
Exemplo n.º 14
0
 public override void Update(UpdateState state)
 {
     this.position = anchor.position;
     Dummy.filter = Color.Lerp(Dummy.filter, Color.Transparent, state.elapsedTime*3f);
 }
Exemplo n.º 15
0
 public override void Update(UpdateState state)
 {
     this.position = anchor.position;
     Dummy.filter  = Color.Lerp(Dummy.filter, Color.Transparent, state.elapsedTime * 3f);
 }
Exemplo n.º 16
0
 public override void Update(UpdateState state)
 {
     oscilation            += state.elapsedTime / 4f;
     drawTexture.position.X = (float)Math.Cos(oscilation) * 2f;
     shadowTexture.position = drawTexture.position - new Vector2(1f, -1f) * (radius / 2f + 1f) * 0.3f;
 }
Exemplo n.º 17
0
 public override void Update(UpdateState state)
 {
 }
Exemplo n.º 18
0
        public override void Update(UpdateState state)
        {
            if (movingForward)
            {
                movingSpeed += 0.05f;
            }
            if (movingBackward)
            {
                movingSpeed -= 0.05f;
            }

            if (movingSpeed > 0f)
            {
                if (movingSpeed > 1f)
                {
                    movingSpeed = 1f;
                }

                position += forward * movingSpeed * state.elapsedTime * 200f;
            }
            else
            {
                if (movingSpeed < -1f)
                {
                    movingSpeed = -1f;
                }

                position += forward * movingSpeed * state.elapsedTime * 100f;
            }

            if (!(movingForward || movingBackward))
            {
                if (Math.Abs(movingSpeed) < 0.15f)
                {
                    movingSpeed = 0f;
                }
                else
                {
                    movingSpeed *= 0.9f;
                }
            }

            if (rotateLeft)
            {
                rotation -= state.elapsedTime * 4f;
            }

            if (rotateRight)
            {
                rotation += state.elapsedTime * 4f;
            }


            //Town Detection and Reaction
            townsInRadius = land.findObjectsInArea <Town>(position, 200f);


            if (townsInRadius.Count != 0)
            {
                guy.filter = Color.Cyan;
            }
            else
            {
                guy.filter = Color.White;
            }

            //MOB encountering
            //creaturesInRange = land.findObjectsInArea<LandCreature>(position, 200f);

            //for (int i = 0; i < creaturesInRange.Count; i++)
            //{
            //    if (creaturesInRange[i].mobProperties != null && creaturesInRange[i].mobProperties.encountering)
            //    {
            //        if ((creaturesInRange[i].position - position).Length() < creaturesInRange[i].mobProperties.encounterRadius + 30f)
            //        {
            //            guy.filter = Color.Red;
            //        }
            //    }
            //}
        }
Exemplo n.º 19
0
 public virtual void Update(UpdateState state)
 {
     this.position += velocity;
     this.rotation += rotationSpeed;
 }
Exemplo n.º 20
0
        public override void Update(UpdateState state)
        {
            if (movingForward)
                movingSpeed += 0.05f;
            if (movingBackward)
                movingSpeed -= 0.05f;

            if (movingSpeed > 0f)
            {
                if (movingSpeed > 1f)
                    movingSpeed = 1f;

                position += forward * movingSpeed * state.elapsedTime * 200f;
            }
            else
            {
                if (movingSpeed < -1f)
                    movingSpeed = -1f;

                position += forward * movingSpeed * state.elapsedTime * 100f;
            }

            if (!(movingForward || movingBackward))
                if (Math.Abs(movingSpeed) < 0.15f)
                    movingSpeed = 0f;
                else
                    movingSpeed *= 0.9f;

            if (rotateLeft)
                rotation -= state.elapsedTime * 4f;

            if (rotateRight)
                rotation += state.elapsedTime * 4f;

            //Town Detection and Reaction
            townsInRadius  = land.findObjectsInArea<Town>(position, 200f);

            if (townsInRadius.Count != 0)
                guy.filter = Color.Cyan;
            else
                guy.filter = Color.White;

            //MOB encountering
            //creaturesInRange = land.findObjectsInArea<LandCreature>(position, 200f);

            //for (int i = 0; i < creaturesInRange.Count; i++)
            //{
            //    if (creaturesInRange[i].mobProperties != null && creaturesInRange[i].mobProperties.encountering)
            //    {
            //        if ((creaturesInRange[i].position - position).Length() < creaturesInRange[i].mobProperties.encounterRadius + 30f)
            //        {
            //            guy.filter = Color.Red;
            //        }
            //    }
            //}
        }
Exemplo n.º 21
0
 public virtual void Update(UpdateState state)
 {
     for (int i = 0; i < controlables.Count; i++)
         controlables[i].Interact(keyboard);
 }
Exemplo n.º 22
0
        public override void Update(UpdateState state)
        {
            if (running)
            {
                currentTime += state.elapsedTime;

                float animationFactor = currentTime / lifetime;

                if (animationFactor > 1f)
                {
                    animationFactor = 1f;
                    ended = true;
                    running = false;
                }

                if (interpolPosition)
                    target.position = originalPosition * (1f - animationFactor) + destinationPosition * animationFactor;

                if (interpolRotation)
                    target.rotation = originalRotation * (1f - animationFactor) + destinationRotation * animationFactor;

                if (interpolSize)
                    ((Resizable)target).setSize(originalSize * (1f - animationFactor) + destinationSize * animationFactor);
            }
            else
            {
                if (ended)
                    destroy();
            }
        }
Exemplo n.º 23
0
        public override void Update(UpdateState state)
        {
            switch (this.state)
            {
                case LandManagerState.loading:

                    if (land.isLoaded())
                    {
                        if (minimapFinishLoadAnimation == null)
                        {
                            minimapLoopAnimation.destroy();
                            minimapLoopAnimation = null;
                            Vector2 minimapPosition = UserInterfaceManager.getCurrentUpperLeftCorner() + new Vector2(100f, 100f);
                            minimapFinishLoadAnimation = new Animation(world, minimap, minimapPosition, 0f, new Vector2(200f, 200f), 1.2f, Animation.InterpolationType.linear, true);
                        }
                        else if(minimapFinishLoadAnimation.isFinished())
                        {
                            minimapFinishLoadAnimation.destroy();
                            minimapFinishLoadAnimation = null;

                            loadPreviewer = null;

                            Rectangle activeBoxArea = gameManager.getActiveBoxArea();
                            activeBox = new LandActiveBox(land, world, new Point(activeBoxArea.Width, activeBoxArea.Height));
                            landCamera = activeBox.camera;

                            LandCameraControl control = new LandCameraControl(land, landCamera);
                            HumanPlayer metaHuman = new HumanPlayer(land);
                            LandHumanPlayer human = new LandHumanPlayer(land, metaHuman, gameManager);

                            PlayerManager.getPlayer("player1").addControlable(human);

                            control.setAnchor(human);

                            land.addContentRequirer(human);
                            land.addUpdateNode(human);

                            activeBox.position = UserInterfaceManager.getUserInterfaceArea("activebox").getCenter();

                            this.state = LandManagerState.inland;
                        }
                    }
                    break;
                case LandManagerState.inland:
                    land.Update(state);
                    break;
            }
        }
Exemplo n.º 24
0
 public override void Update(UpdateState state)
 {
     texture.Phase += state.elapsedTime;
     base.Update(state);
 }
Exemplo n.º 25
0
        public override void Update(UpdateState state)
        {
            if (running)
            {
                currentTime += state.elapsedTime;

                phase = initialPhase + (currentTime / looptime);

                switch (interpolationType)
                {
                    case InterpolationType.linear:
                        phase *= 2f;

                        // clamp phase between 0 and 2
                        phase = phase - (((int)phase) / 2) * 2f;

                        // invert
                        if (phase > 1f)
                            phase = 2f - phase;
                        break;
                    case InterpolationType.Trignometric:
                        phase = 1f - ((float)Math.Cos(phase*Math.PI*2f) + 1f)/2f;
                        break;
                }

                if (interpolPosition)
                    target.position = originalPosition * (1f - phase) + destinationPosition * phase;

                if (interpolRotation)
                    target.rotation = originalRotation * (1f - phase) + destinationRotation * phase;

                if (interpolSize)
                    ((Resizable)target).setSize(originalSize * (1f - phase) + destinationSize * phase);
            }
            else
            {
                if (ended)
                    destroy();
            }
        }
Exemplo n.º 26
0
 public override void Update(UpdateState state)
 {
     oscilation += state.elapsedTime/4f;
     drawTexture.position.X = (float)Math.Cos(oscilation) * 2f;
     shadowTexture.position = drawTexture.position - new Vector2(1f, -1f)*(radius/2f + 1f)*0.3f;
 }