Exemplo n.º 1
0
 private void Awake()
 {
     s_instance = this;
     if (UniversalInputManager.UsePhoneUI != null)
     {
         Transform transform = this.m_menuButton.transform;
         transform.localScale = (Vector3)(transform.localScale * 2f);
         Transform transform2 = this.m_friendButton.transform;
         transform2.localScale = (Vector3)(transform2.localScale * 2f);
     }
     else
     {
         this.m_connectionIndicator.gameObject.SetActive(false);
     }
     this.m_initialWidth = base.GetComponent <Renderer>().bounds.size.x;
     this.m_initialFriendButtonScaleX = this.m_friendButton.transform.localScale.x;
     this.m_initialMenuButtonScaleX   = this.m_menuButton.transform.localScale.x;
     this.m_menuButton.AddEventListener(UIEventType.RELEASE, new UIEvent.Handler(this.OnMenuButtonReleased));
     this.m_friendButton.AddEventListener(UIEventType.RELEASE, new UIEvent.Handler(this.OnFriendButtonReleased));
     this.ToggleEnableButtons(false);
     this.m_batteryLevel.gameObject.SetActive(false);
     FatalErrorMgr.Get().AddErrorListener(new FatalErrorMgr.ErrorCallback(this.OnFatalError));
     SceneMgr.Get().RegisterSceneLoadedEvent(new SceneMgr.SceneLoadedCallback(this.OnSceneLoaded));
     SpectatorManager.Get().OnInviteReceived       += new SpectatorManager.InviteReceivedHandler(this.SpectatorManager_OnInviteReceived);
     SpectatorManager.Get().OnSpectatorToMyGame    += new SpectatorManager.SpectatorToMyGameHandler(this.SpectatorManager_OnSpectatorToMyGame);
     SpectatorManager.Get().OnSpectatorModeChanged += new SpectatorManager.SpectatorModeChangedHandler(this.SpectatorManager_OnSpectatorModeChanged);
     ApplicationMgr.Get().WillReset += new System.Action(this.WillReset);
     this.m_lightingBlend = this.m_menuButtonMesh.GetComponent <Renderer>().material.GetFloat("_LightingBlend");
     if (UniversalInputManager.UsePhoneUI != null)
     {
         this.m_batteryLevel = this.m_batteryLevelPhone;
         this.m_currentTime.gameObject.SetActive(false);
     }
     this.m_menuButton.SetPhoneStatusBarState(0);
 }
Exemplo n.º 2
0
        public PlayerButton(Player Player, Action <object> OnClick, Vector2 ButtonOffset)
            : base(ButtonType.PlayerButton, DepthParameter.InterfaceButton, OnClick, ButtonOffset)
        {
            //Hide button placeholder
            spriteList   = new List <Sprite>();
            flipbookList = new List <Flipbook>();

            ButtonSprite.Color = Color.Transparent;
            this.Player        = Player;

            //Since the button elements dont update, the screencenter
            //must be added in order to create the right position
            //on the elements
            ButtonOffset += Parameter.ScreenCenter;

            int sidePositionFactor = (Player.PlayerTeam == PlayerTeam.Red) ? 1 : -1;

            PlayerStatus = new Flipbook(
                ButtonOffset + new Vector2(82 * sidePositionFactor, 0),
                new Vector2((296 / 4) / 2, 76 / 2),
                74, 76, "Interface/StaticButtons/GameRoom/Player/StatusMarker",
                PlayerStatusPreset[Player.PlayerTeam][Player.PlayerRoomStatus],
                DepthParameter.InterfaceButtonIcon);
            flipbookList.Add(PlayerStatus);

            PlayerStatusText = new Flipbook(
                ButtonOffset + new Vector2(78 * sidePositionFactor, 28),
                new Vector2((150 / 3) / 2, 16 / 2),
                50, 16, "Interface/StaticButtons/GameRoom/Player/StatusText",
                PlayerStatusTextPreset[Player.PlayerTeam][Player.PlayerRoomStatus],
                DepthParameter.InterfaceButtonText);
            flipbookList.Add(PlayerStatusText);

            spriteList.Add(new Sprite("Interface/StaticButtons/GameRoom/Player/Shadow",
                                      ButtonOffset + new Vector2(-20 * sidePositionFactor, 33),
                                      DepthParameter.Mobile - 0.01f));

            Mobile = ActorBuilder.BuildMobile(Player.PrimaryMobile, Player, ButtonOffset + new Vector2(-20 * sidePositionFactor, 7), false);
            Mobile.Rider.Update();

            if (Player.PlayerTeam == PlayerTeam.Red)
            {
                Mobile.Flip();
            }

            Nameplate = new Nameplate(Player, Alignment.Left, ButtonOffset - new Vector2(100, 47));

            Mobile.MobileFlipbook.JumpToRandomAnimationFrame();
        }
Exemplo n.º 3
0
        public IncomingWeatherPointer(WeatherMetadata weatherMetadata)
        {
            WeatherMetadata = weatherMetadata;

            fadeAnimation = 0;

            position = Topography.FromNormalizedPositionToRelativePosition(weatherMetadata.Position);
            flipbook = new Flipbook(Vector2.Zero, new Vector2(9, -11), 19, 27, "Interface/InGame/HUD/Blue/IncomingWeather/Pointer", new AnimationInstance {
                EndingFrame = 6, TimePerFrame = 1 / 15f
            }, 0.95f, 0);

            string text;

            switch (weatherMetadata.Weather)
            {
            case WeatherType.Force:
                text = Language.WeatherForce;
                break;

            case WeatherType.Tornado:
                text = Language.WeatherTornado;
                break;

            case WeatherType.Electricity:
                text = Language.WeatherElectricity;
                break;

            case WeatherType.Weakness:
                text = Language.WeatherWeakness;
                break;

            case WeatherType.Mirror:
                text = Language.WeatherMirror;
                break;

            default:
                text = Language.WeatherRandom;
                break;
            }

            spriteText = new SpriteText(FontTextType.Consolas10, text, Color.White, Alignment.Center, layerDepth: 1);

            flipbook.Position   = new Vector2(position.X, -(GameScene.Camera.CameraOffset + Parameter.ScreenResolution / 2).Y);
            spriteText.Position = flipbook.Position + new Vector2(0, 0);

            flipbook.Color = spriteText.Color = spriteText.OutlineColor = Color.Transparent;
        }
Exemplo n.º 4
0
        public virtual void Update(Vector2 projectilePosition, Vector2 angularPositionOffset, float currentProjectileAngle, float elapsedTime, float angleOffset, float rotationFactor = 1f, float angleFactor = 1f)
        {
            rotationAngle += elapsedTime * MathHelper.TwoPi * rotationFactor;

            //Update DC
            positionRotatedOffset = Vector2.Transform(angularPositionOffset * (float)Math.Sin(rotationAngle + angleOffset) * angleFactor, Matrix.CreateRotationZ(currentProjectileAngle));
            positionOffset = projectilePosition + positionRotatedOffset;

            if (lastSpawn == null || Vector2.Distance(lastSpawn, positionOffset) > 8)
            {
                //Top
                Flipbook newFlipbook = SpawnFlipbook(mobileType, shotType);
                newFlipbook.Position = positionOffset;
                newFlipbook.SetTransparency(0);

                lastSpawn = positionOffset;

                traceList.Add(newFlipbook);

                float f = 1;
                for (int i = traceList.Count - 1; i >= 0; i--, f -= 0.03f)
                {
                    if (i - 1 >= 0)
                    {
                        var prev = traceList[i - 1];
                        var curr = traceList[i];
                        curr.Rotation = (float)Helper.AngleBetween(curr.Position, prev.Position) + MathHelper.Pi / 2;
                    }

                    traceList[i].Color = Color * f;
                }
            }

            leadTrace.Position = positionOffset;
            leadTrace.Rotation = currentProjectileAngle;

            #if DEBUG
            dc0.Update(projectilePosition);
            dc1.Update(positionRotatedOffset + projectilePosition);
            #endif
        }
Exemplo n.º 5
0
        public KnightSword(Mobile Owner) : base(Owner)
        {
            Flipbook = new Flipbook(Vector2.Zero,
                                    new Vector2(48 / 2, 30 / 2),
                                    48, 31,
                                    "Graphics/Tank/Knight/Satellite",
                                    StatePresets[SatelliteFlipbookState],
                                    DepthParameter.MobileSatellite);

            oscilationAmplitude    = 3f;
            oscilationCurrentAngle = 0f;
            oscilationAngleFactor  = 5f;

            CurrentOffset  = S1OwnerOffset = new Vector2(0, Parameter.ProjectileKnightS1OwnerOffset);
            S2OwnerOffset  = new Vector2(0, Parameter.ProjectileKnightS2OwnerOffset);
            SSTargetOffset = new Vector2(0, Parameter.ProjectileKnightSSOwnerOffset);

            AttackingTarget = Owner;

            CannonPositionOffset = 15;
        }
Exemplo n.º 6
0
        public ThorSatellite()
        {
            targetList = new List <Projectile>();

            beamColor = Parameter.NeonGreen;

            oscilatingPositionOffset = new Vector2(3, 0);
            cannonOffset             = new Vector2(50, 0);

            position = new Vector2(0, -500);

            flipbook = new Flipbook(position, new Vector2(118, 111), 197, 190, "Graphics/Entity/Thor/Spritesheet", thorStatePresets[ActorFlipbookState.Stand], DepthParameter.Mobile, MathHelper.PiOver2);

            levelSpriteFont      = new NumericSpriteFont(FontType.HUDBlueThorLevelIndicator, 1, DepthParameter.MobileSatellite, textAnchor: TextAnchor.Right, attachToCamera: false, StartingValue: 1);
            experienceSpriteFont = new CurrencySpriteFont(FontType.HUDBlueThorExperienceIndicator, 5, DepthParameter.MobileSatellite, textAnchor: TextAnchor.Right, attachToCamera: false);

            levelText       = new Sprite("Interface/Spritefont/HUD/Blue/ThorLevelLV", Vector2.Zero, layerDepth: DepthParameter.MobileSatellite);
            levelText.Pivot = Vector2.Zero;

            lastFocusedPosition = Vector2.Zero;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Makes the weatherEffect to move down and loop on screen
        /// </summary>
        public void VerticalScrollingUpdate(GameTime gameTime)
        {
            animationVerticalScrollingOffset += new Vector2(0, Parameter.WeatherEffectVerticalScrollingUpdateSpeed) * (float)gameTime.ElapsedGameTime.TotalSeconds;

            //Update position
            if (animationVerticalScrollingOffset.Y >= 1)
            {
                Vector2 roundOffset = new Vector2((float)Math.Round(animationVerticalScrollingOffset.X), (float)Math.Round(animationVerticalScrollingOffset.Y));
                flipbookList.ForEach((x) => x.Position += roundOffset);
                animationVerticalScrollingOffset        = Vector2.Zero;
            }

            //Move the flipbook to the origin
            Flipbook lE = flipbookList.Last();

            if (lE.Position.Y - lE.SourceRectangle.Height * Scale >= Topography.MapHeight / 2)
            {
                lE.Position = flipbookList[0].Position - new Vector2(0, lE.Pivot.Y * 2) * Scale;
                int newFrame = flipbookList[0].GetCurrentFrame() - 1;
                lE.SetCurrentFrame(newFrame < 0 ? (numberOfFrames - 1) : newFrame);
                flipbookList.Remove(lE);
                flipbookList.Insert(0, lE);
            }
        }
Exemplo n.º 8
0
        public InteractiveObject(InteractiveObjectData metaData, string objectName, float[,] perspectiveMap, InteractiveObjectRef interactiveObjectRef)
        {
            InteractiveObjectRef = interactiveObjectRef;
            this.PerspectiveMap  = perspectiveMap;
            this.Type            = INTERACTIVE_ENTITY_TYPE;
            images   = new List <Image>();
            MetaData = metaData;

            if (MetaData.Commands != null)
            {
                foreach (var c in MetaData.Commands)
                {
                    c.parent = this;
                }
            }

            int totalFrames = 0;

            foreach (var animation in MetaData.Animations)
            {
                int frameNumber = 0;
                foreach (string path in Utility.RetrieveFilePathForFilesInDirectory(@"./content/objects/" + objectName + @"/" + animation.Name, "*.png"))
                {
                    images.Add(new Image(Library.GetTexture(path))
                    {
                        Scale = scale, OriginX = MetaData.HotSpot.X, OriginY = MetaData.HotSpot.Y
                    });
                    if (animation.FootStepFrames != null && animation.FootStepFrames.Contains(frameNumber + 1))
                    {
                        int frame = frameNumber + totalFrames;
                        if (!footFallFrames.ContainsKey(animation.Name))
                        {
                            footFallFrames.Add(animation.Name, new List <int> {
                                frame
                            });
                        }
                        else
                        {
                            footFallFrames[animation.Name].Add(frame);
                        }
                    }

                    frameNumber++;
                }
                totalFrames += frameNumber;
            }
            sprite = new Flipbook(images.Cast <Graphic>().ToArray());

            int currentTotalFrames = 0;

            foreach (var animation in MetaData.Animations)
            {
                sprite.Add(animation.Name, FP.MakeFrames(currentTotalFrames, (currentTotalFrames += animation.Frames) - 1), animation.FPS, true);
            }
            AddComponent(sprite);
            this.OriginX = MetaData.HotSpot.X * scale;
            this.OriginY = MetaData.HotSpot.Y * scale;
            SetHitbox((int)(MetaData.FrameSize.X * scale), (int)(MetaData.FrameSize.Y * scale), (int)this.OriginX, (int)this.OriginY);
            if (perspectiveMap != null)
            {
                UpdateLayer();
            }

            if (metaData.Attributes == null)
            {
                metaData.Attributes = new Dictionary <string, int>();
            }
            if (interactiveObjectRef.Attributes == null)
            {
                interactiveObjectRef.Attributes = new Dictionary <string, int>();
            }

            foreach (var key in metaData.Attributes.Keys)
            {
                if (!interactiveObjectRef.Attributes.ContainsKey(key))
                {
                    interactiveObjectRef.Attributes.Add(key, metaData.Attributes[key]);
                }
            }
        }
Exemplo n.º 9
0
        public ServerButton(GameServerInformation serverInformation, Vector2 buttonPosition, Action <object> action)
            : base(ButtonType.ServerListButton, DepthParameter.InterfaceButton, action, buttonPosition, default)
        {
            //Since the button elements dont update, the screencenter
            //must be added in order to create the right position
            //on the elements
            buttonPosition += Parameter.ScreenCenter;

            //Initializing Variables
            compositeSpriteTextList = new List <CompositeSpriteText>();
            spriteList        = new List <Sprite>();
            flipbookList      = new List <Flipbook>();
            spriteTextList    = new List <SpriteText>();
            ServerInformation = serverInformation;

            //Server Background
            if (!serverInformation.IsOnline)
            {
                ChangeButtonState(ButtonAnimationState.Disabled);
            }

            //Server Level Indication Icons
            int lowerLevel  = (int)serverInformation.LowerLevel;
            int higherLevel = (int)serverInformation.HigherLevel;

            Sprite lowerLevelIcon  = IconBuilder.Instance.BuildServerIcon((ServerRankLimitationIcon)(lowerLevel * 2), DepthParameter.InterfaceButtonText);
            Sprite higherLevelIcon = IconBuilder.Instance.BuildServerIcon((ServerRankLimitationIcon)(higherLevel * 2 + 1), DepthParameter.InterfaceButtonText);
            Sprite avatarIcon      = IconBuilder.Instance.BuildServerIcon((serverInformation.IsAvatarOn ? ServerRankLimitationIcon.AvatarOn : ServerRankLimitationIcon.AvatarOff), DepthParameter.InterfaceButtonText);

            lowerLevelIcon.Position  = buttonPosition + new Vector2(40, -24);
            higherLevelIcon.Position = buttonPosition + new Vector2(68, -24);
            avatarIcon.Position      = buttonPosition + new Vector2(96, -24);

            spriteList.Add(lowerLevelIcon);
            spriteList.Add(higherLevelIcon);
            spriteList.Add(avatarIcon);

            //Server Load Icon
            ServerStatusFlipbookIcon serverLoad = GetCurrentServerLoadIcon(serverInformation);
            Flipbook icon = new Flipbook(
                buttonPosition + new Vector2(130, 12), new Vector2(31, 37), 62, 58,
                "Interface/InGame/Scene/ServerList/ServerStatusAnimatedIcon", serverLoad.FlipbookInstance, DepthParameter.InterfaceButtonAnimatedIcon);

            flipbookList.Add(icon);

            //Server Button Texts
            SpriteText[] sprT = new SpriteText[2];
            sprT[0] = new SpriteText(Parameter.ServerButtonFont, $"{serverInformation.ServerID}. ", Color.DarkOrange,
                                     Alignment.Left, DepthParameter.InterfaceButtonText, outlineColor: Color.Black);

            sprT[1] = new SpriteText(Parameter.ServerButtonFont, serverInformation.ServerName, Color.White,
                                     Alignment.Left, DepthParameter.InterfaceButtonText, outlineColor: Color.Black);

            compositeSpriteTextList.Add(
                CompositeSpriteText.CreateCompositeSpriteText(sprT.ToList(), Orientation.Horizontal, Alignment.Left, buttonPosition + new Vector2(-155, -32), 0));

            sprT = new SpriteText[serverInformation.ServerDescription.Count()];
            for (int i = 0; i < serverInformation.ServerDescription.Count(); i++)
            {
                sprT[i] = new SpriteText(Parameter.ServerButtonFont, serverInformation.ServerDescription[i], Color.White,
                                         Alignment.Left, DepthParameter.InterfaceButtonText, outlineColor: Color.Black);
            }

            compositeSpriteTextList.Add(CompositeSpriteText.CreateCompositeSpriteText(sprT.ToList(), Orientation.Vertical, Alignment.Left, buttonPosition + new Vector2(-155, -10), -1));

            if (serverInformation.IsOnline)
            {
                spriteTextList.Add(new SpriteText(Parameter.ServerButtonFont, $"[{serverInformation.ConnectedClients}/{serverInformation.ConnectedClientCapacity}]", Color.White,
                                                  Alignment.Center, DepthParameter.InterfaceButtonText, buttonPosition + new Vector2(68, -10), Color.Black));
            }

            //Server Icon Text
            spriteTextList.Add(new SpriteText(Parameter.ServerButtonFont,
                                              serverLoad.IconSubtitle, Color.White, Alignment.Center,
                                              DepthParameter.InterfaceButtonText, icon.Position + new Vector2(0, 10), Color.Black));

            OnBeingPressed = (sender) =>
            {
                spriteTextList.ForEach((x) => x.Position += new Vector2(1, 1));
                spriteList.ForEach((x) => x.Position     += new Vector2(1, 1));
                flipbookList.ForEach((x) => x.Position   += new Vector2(1, 1));
            };

            OnBeingReleased = (sender) =>
            {
                spriteTextList.ForEach((x) => x.Position -= new Vector2(1, 1));
                spriteList.ForEach((x) => x.Position     -= new Vector2(1, 1));
                flipbookList.ForEach((x) => x.Position   -= new Vector2(1, 1));
            };
        }
Exemplo n.º 10
0
        /// <summary>
        /// Instances all Flipbooks in position and set it's animations
        /// </summary>
        public virtual void Initialize(string texturePath, Vector2 startingPosition, WeatherAnimationType animationType, int extraSpawns = 0, float layerDepth = DepthParameter.WeatherEffect)
        {
            Vector2 endingPosition = new Vector2(Topography.MapWidth, Topography.MapHeight) / 2;

            //Creates the initial offset and 'subtracts' the pivot influence of the element.
            Vector2 currentOffset = startingPosition + Vector2.Transform(new Vector2(0, flipbookPivot.Y), Matrix.CreateRotationZ(rotation)) * Scale;

            int     startingFrame   = 0;
            Vector2 temporaryOffset = Vector2.Zero;

            do
            {
                currentOffset += temporaryOffset;

                //FixedAnimationsFrames is used on random
                //VariableAnimationFrame is used on tornado, weakness and force
                AnimationInstance animation = new AnimationInstance()
                {
                    TimePerFrame = 1 / 15f
                };

                switch (animationType)
                {
                case WeatherAnimationType.FixedAnimationFrame:
                    animation.StartingFrame = animation.EndingFrame = startingFrame % numberOfFrames;
                    break;

                case WeatherAnimationType.VariableAnimationFrame:
                    animation.EndingFrame = numberOfFrames - 1;
                    break;
                }

                startingFrame++;

                Flipbook fb = new Flipbook(currentOffset, flipbookPivot, (int)flipbookPivot.X * 2, (int)flipbookPivot.Y * 2, texturePath, animation, DepthParameter.WeatherEffect, rotation);
                fb.Scale *= Scale;
                flipbookList.Add(fb);

                fb.SetCurrentFrame(startingFrame % numberOfFrames);

                if (temporaryOffset == Vector2.Zero)
                {
                    temporaryOffset = Vector2.Transform(new Vector2(0, fb.SpriteHeight), Matrix.CreateRotationZ(rotation)) * Scale;
                }

                //While it is inside the map boundaries and extraSpawns is not 0
            } while (Topography.IsInsideMapBoundaries(currentOffset) || extraSpawns-- > 0);

            //If the rotation isn't 0 it means there are no good reasons for collision boxes
            if (rotation == 0)
            {
                collisionRectangle = new Rectangle((int)(startingPosition.X - collisionRectangleOffset.X * Scale), (int)startingPosition.Y,
                                                   (int)(collisionRectangleOffset.X * 2 * Scale), (int)(endingPosition.Y - startingPosition.Y));

                outerCollisionRectangle = new Rectangle(collisionRectangle.X - (int)outerCollisionRectangleOffset.X, collisionRectangle.Y - (int)outerCollisionRectangleOffset.Y,
                                                        collisionRectangle.Width + (int)outerCollisionRectangleOffset.X * 2, collisionRectangle.Height + 10 * 2);

#if DEBUG
                debugRectangle = new DebugRectangle(Color.Blue);
                debugRectangle.Update(collisionRectangle);
                DebugHandler.Instance.Add(debugRectangle);
                outerDebugRectangle = new DebugRectangle(Color.Red);
                outerDebugRectangle.Update(outerCollisionRectangle);
                DebugHandler.Instance.Add(outerDebugRectangle);
#endif
            }
        }