Пример #1
0
        public StartButton()
        {
            Type   = "ButtonState";
            Button = Image.CreateRect(400, 200, FP.Color(0xFFFFFF));
            var Title = new Text("Start", 0, 0, 0, 0);

            Title.Size  = 100;
            Title.Color = FP.Color(0x000000);
            var Instructions = new Text("Instructions: W,A,S,D Control, Right Mouse to Shoot, Left Mouse to Grab Floating Parts.", 0, 0, 0, 0);

            AddGraphic(Button);
            AddGraphic(Title);
            AddGraphic(Instructions);

            Instructions.CenterOO();
            Instructions.Size  = 20;
            Instructions.Color = FP.Color(0xffffff);
            Instructions.X    -= 450;
            Instructions.Y    -= 200;
            Title.CenterOO();
            Title.X -= 125;
            Title.Y -= 75;
            SetHitboxTo(Button);
            CenterOrigin();
            Button.CenterOO();
            Button.CenterOrigin();
            X = FP.HalfWidth;
            Y = FP.HalfHeight + 100;
            FP.Log(Instructions.X, Instructions.Y);
        }
Пример #2
0
        private void LoadRobots(Library.ILibraryInternal library)
        {
            string json = null;

            if (Library.FolderExists(TWITCH_CACHE_PATH))
            {
                var qualifiedFilename = string.Format("{0}{1}.json", TWITCH_CACHE_PATH, "robots");
                if (Library.FileExists(qualifiedFilename))
                {
                    json = File.ReadAllText(Library.GetFilename(qualifiedFilename));
                }
            }

            if (json == null)
            {
                throw new Exception("Can't find robots!");
            }

            var robots = Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <string, string> >(json);

            if (robots == null)
            {
                throw new Exception("Failed to create robot dictionary");
            }

            foreach (var pair in robots)
            {
                try {
                    AddEmote(pair.Key, pair.Value, library);
                } catch (Exception) {
                    FP.Log("Failed to load robot", pair.Key);
                }
            }
        }
Пример #3
0
        public override void OnLifetimeComplete()
        {
            base.OnLifetimeComplete();

            FP.Log("u can b unfrozen now bro");
            owner.SetUpgrade(null);
        }
Пример #4
0
        public Room()
        {
            foreach (string file in Directory.EnumerateFiles("assets/Levels/", "*.oel"))
            {
                FP.Log("PreloadingXML");
                Library.GetXml(file);
            }
            Library.GetBuffer("assets/Bossedd.ogg");
            roomLoader = new Thread(LoadRooms);
            roomLoader.IsBackground = true;
            RegisterClass <wallColTile>("wallCollision");
            RegisterClass <Platform>("platform");
            RegisterClass <GfxTile>("wallGfx");
            RegisterClass <Door>("door");
            RegisterClass <PlayerSpawn>("playerSpawn");
            RegisterClass <GroundEnemy>("groundEnemy");
            RegisterClass <TextObj>("textObj");
            RegisterClass <FlyingEnemy>("flyingEnemy");
            RegisterClass <Chest>("chest");
            RegisterClass <Boss>("bossSpawn");
            RegisterClass <BackDrop>("backDrop");

            AddList(currentEnts = BuildWorldAsArray("assets/Levels/Level01.oel"));

            Add(cursor = new Cursor());
            musics     = new Sfx(Library.GetBuffer("assets/Preview2.ogg"));
        }
Пример #5
0
 private void OnTriggerOff(params object[] args)
 {
     if (String.Equals(args[0] as string, Group))
     {
         FP.Log("I was triggered off. Group: " + Group);
         TriggerOff();
     }
 }
Пример #6
0
        private void LoadChannelBttvSet(Library.ILibraryInternal library, string channel)
        {
            string json = null;

            var qualifiedFilename = string.Format("{0}{1}_{2}.json", TWITCH_CACHE_PATH, "bttv", channel);

            try
            {
                json = client.DownloadString(string.Format("https://api.betterttv.net/2/channels/{0}", channel));
                if (!String.IsNullOrEmpty(json))
                {
                    File.WriteAllText(qualifiedFilename, json);
                }
                else
                {
                    json = null;
                }
            }
            catch
            {
                json = null;
            }

            if (json == null)
            {
                if (Library.FileExists(qualifiedFilename))
                {
                    json = File.ReadAllText(Library.GetFilename(qualifiedFilename));
                }
                else
                {
                    return;
                }
            }


            var api = Newtonsoft.Json.JsonConvert.DeserializeObject <BaseBttvAPI>(json);

            foreach (var emote in api.emotes)
            {
                try
                {
                    if (File.Exists(string.Format("{0}{1}", TWITCH_CACHE_PATH, Utility.EncodeStringForFileName(emote.code))))
                    {
                        AddEmote(emote.code, emote.code, library);
                    }
                    else
                    {
                        AddBttvEmote(emote.code, emote.id, library);
                    }
                    LoadedSpecialEmotes.Add(emote.code);
                }
                catch (Exception e)
                {
                    FP.Log(emote.code, e.Message);
                }
            }
        }
Пример #7
0
        private void LoadGlobalSet(Library.ILibraryInternal library)
        {
            string json = null;
            var    qualifiedFilename = string.Format("{0}{1}.json", TWITCH_CACHE_PATH, "global");

            try
            {
                json = client.DownloadString(string.Format("https://twitchemotes.com/api_cache/v2/{0}.json", "global"));
                if (!String.IsNullOrEmpty(json))
                {
                    File.WriteAllText(qualifiedFilename, json);
                }
                else
                {
                    json = null;
                }
            }
            catch
            {
                json = null;
            }

            if (json == null)
            {
                if (Library.FileExists(qualifiedFilename))
                {
                    json = File.ReadAllText(Library.GetFilename(qualifiedFilename));
                }
                else
                {
                    return;
                }
            }

            var api = Newtonsoft.Json.JsonConvert.DeserializeObject <GlobalEmoteAPI>(json);

            foreach (var pair in api.emotes)
            {
                try
                {
                    if (File.Exists(string.Format("{0}{1}", TWITCH_CACHE_PATH, pair.Key)))
                    {
                        AddEmote(pair.Key, pair.Key, library);
                    }
                    else
                    {
                        AddTwitchEmote(pair.Key, pair.Value.image_id, library);
                    }
                }
                catch (Exception e)
                {
                    FP.Log(pair.Key, e.Message);
                }
            }
        }
Пример #8
0
        public override EffectMessage MakeEffect()
        {
            EffectMessage.Callback callback = delegate(Entity from, Entity to, float scalar)
            {
                to.AddComponent(new Freeze(to.X, to.Y, Lifetime));
            };

            FP.Log("FROZEN FOR ", Lifetime, " SECONDS YO");

            return(new EffectMessage(owner, callback));
        }
Пример #9
0
        public override void Update()
        {
            base.Update();
            lifetime -= FP.Elapsed;

            if (lifetime <= 0)
            {
                FP.Log("gone pls");
                Parent.RemoveComponent(this);
                return;
            }

            Parent.X = x;
            Parent.Y = y;
        }
Пример #10
0
        public override void Load(System.Xml.XmlNode node)
        {
            base.Load(node);
            Graphic = Image.CreateRect(64, 64, FP.Color(0x66FF33));
            Type    = "platform";

            foreach (System.Xml.XmlNode n in node)
            {
                FP.Log(int.Parse(n.Attributes["x"].Value) + " " + float.Parse(n.Attributes["y"].Value));
                positionNodes.Add(new Vector2i(int.Parse(n.Attributes["x"].Value), int.Parse(n.Attributes["y"].Value)));
            }
            if (positionNodes.Count > 0)
            {
                currentPosition = positionNodes[0];
                MoveToNextPos();
            }

            SetHitbox(64, 64, 0, 0);
        }
Пример #11
0
        public override void Load(System.Xml.XmlNode node)
        {
            base.Load(node);
            //Graphic = Image.CreateRect(64, 64, FP.Color(0x66FF33));

            //make the enemy hittable and all that jazz
            Type    = "enemy";
            physics = new PhysicsBody();
            physics.Colliders.Add("wall");
            physics.Colliders.Add("platform");
            physics.Colliders.Add("player");
            AddLogic(physics);

            //hitboxs and such
            spritemap = new Spritemap(Library.GetTexture("assets/RoadHeadlowres.png"), 167 / 2, 257 / 2, onAnimationEnd);
            spritemap.Add("Idle", FP.Frames(0), 5, true);
            spritemap.Add("Move", FP.MakeFrames(0, 2), 5, true);
            spritemap.Add("ChargeAttack", FP.MakeFrames(3, 12), 8, false);
            spritemap.Add("Attack", FP.MakeFrames(13, 22), 8, false);
            spritemap.Add("Recover", FP.MakeFrames(23, 27), 5, false);
            spritemap.Add("Injured", FP.MakeFrames(27, 23), 5, true);
            spritemap.Play("Move");

            spritemap.OriginX = spritemap.Width / 2;
            spritemap.OriginY = spritemap.Height;
            AddGraphic(spritemap);

            SetOrigin(spritemap.Width / 2, 257 / 2);
            SetHitbox(spritemap.Width, spritemap.Height, spritemap.Width / 2, spritemap.Height);

            foreach (System.Xml.XmlNode n in node)
            {
                FP.Log(int.Parse(n.Attributes["x"].Value) + " " + float.Parse(n.Attributes["y"].Value));
                positionNodes.Add(new Vector2i(int.Parse(n.Attributes["x"].Value), int.Parse(n.Attributes["y"].Value)));
            }


            if (positionNodes.Count > 0)
            {
                nextNode = positionNodes[0];
                MoveToNextPos();
            }
        }
Пример #12
0
        public override void Update()
        {
            base.Update();
            if ((World as Room).RoomsAreLoading)
            {
                (Graphic as Image).Color = FP.Color(0xFF00AA);
            }
            else
            {
                (Graphic as Image).Color = FP.Color(0xFF0000);
            }
            if (Collide(Player.CollisionType, X, Y) != null)
            {
                FP.Log("Collided with player");

                if (!(World as Room).RoomsAreLoading && Input.Pressed(Keyboard.Key.W))
                {
                    (World as Room).NextRoom(this);
                }
            }
        }