예제 #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="hand">True for left hand image, false for right.</param>
        public Fist(bool hand, Player parent)
        {
            ForceMultiplier = DEFAULT_PUNCH_MULT;
            forceVector     = new Vector2f();

            backHand    = hand;
            this.parent = parent;
            punchy      = false;
            Punching    = false;
            canPunch    = true;

            Layer = ObjectLayers.JustAbove(ObjectLayers.Players);

            Image = new Image(Library.GetTexture("glove" + (backHand ? "2" : "1") + ".png"));
            Image.CenterOO();
            AddComponent(Image);

            SetHitboxTo(Image);
            CenterOrigin();

            Type = Collision;

            if (backHand)
            {
                offsetY = BackOffsetY;
            }
            else
            {
                offsetY = FrontOffsetY;
            }

            FaceRight();
        }
예제 #2
0
        public void NodeHandler(System.Xml.XmlNode entity)
        {
            myImage  = new Image(Library.GetTexture("pivot.png"));
            razorArm = new Image(Library.GetTexture("razorArm.png"));

            razorArm.ScaleX = distance * 32 / razorArm.Width;

            myImage.CenterOO();
            razorArm.OriginY = razorArm.Height / 2;

            theRazor   = new RazorBlade(size);
            theRazor.X = X;
            theRazor.Y = Y;

            Layer          = ObjectLayers.JustAbove(ObjectLayers.Players);
            theRazor.Layer = ObjectLayers.JustAbove(Layer);

            theRazor.X += razorArm.ScaledWidth;

            rotation = -90;

            speed *= 0.5f;

            AddComponent(razorArm);
            AddComponent(myImage);
            SetHitbox((int)(myImage.Width), (int)(myImage.Height), (int)(myImage.X + myImage.Width / 2), (int)(myImage.Y + myImage.Height / 2));
        }
예제 #3
0
 public ILayer <GameActor> GetLayer(LayerType layerType)
 {
     if (layerType == LayerType.Object ||
         layerType == LayerType.ForegroundObject)
     {
         return(ObjectLayers.FirstOrDefault(x => x.LayerType == layerType));
     }
     return(TileLayers.FirstOrDefault(x => x.LayerType == layerType));
 }
예제 #4
0
        public GlobalEmitter()
        {
            AddResponse(Message.GroundSmash, DelegateEmit(InitGroundSmash()));
            AddResponse(Message.BulletTrail, DelegateEmit(InitBulletTrail()));
            AddResponse(Message.SuperSpeed, DelegateEmit(InitSpeed()));
            AddResponse(Message.DoubleJump, DelegateEmit(InitDoubleJump()));

            Layer = ObjectLayers.JustAbove(ObjectLayers.Players);
        }
예제 #5
0
        public OffscreenCursor(string ImageName)
        {
            cursor       = new Entity();
            cursor.Layer = ObjectLayers.JustBelow(ObjectLayers.HUD);
            image        = cursor.AddComponent(new Image(Library.GetTexture("cursor.png")));
            image.CenterOrigin();
            image.OriginX = image.Width * 0.35f;

            var face = cursor.AddComponent(new Image(Library.GetTexture("players/" + ImageName + "_head.png")));

            face.CenterOO();
        }
예제 #6
0
        public DrawEnding()
        {
            X     = FP.Camera.X;
            Y     = FP.Camera.Y;
            Layer = ObjectLayers.JustAbove(ObjectLayers.Background);

            var bg = AddComponent(Image.CreateRect(FP.Width, FP.Height, new Color()));

            bg.CenterOO();

            var text = AddComponent(new Text("Draw!"));

            text.Font       = Library.GetFont("fonts/Laffayette_Comic_Pro.ttf");
            text.Italicized = true;
            text.Y          = -(FP.Height / 4);
            text.Size       = 64;
            text.CenterOrigin();
        }
예제 #7
0
        public VictoryEnding(Player winner)
        {
            Winner = winner;
            X      = FP.Camera.X;
            Y      = FP.Camera.Y;
            Layer  = ObjectLayers.JustAbove(ObjectLayers.Background);

            var bg = AddComponent(Image.CreateRect(FP.Width, FP.Height, new Color()));

            bg.CenterOO();

            var image = AddComponent(new Image(Library.GetTexture("happy.png")));

            image.CenterOO();

            // YOU WIN!
            var text = AddComponent(new Text("\tPlayer " + (Winner.PlayerId + 1) + "\nis the true hero!"));

            text.Y    = -(FP.Height / 4);
            text.Font = Library.GetFont("fonts/Laffayette_Comic_Pro.ttf");
            text.Size = 64;
            text.CenterOrigin();

            Tweener.Tween(Winner, new { X = FP.Camera.X, Y = FP.Camera.Y }, 1.2f)
            .Ease(Ease.ElasticOut);

            HypeTween.StartHype(Tweener, image, 1);
            Tweener.Tween(image, new { Angle = 359 }, 20)
            .Repeat();

            Tweener.Tween(image, new { Scale = 1.7f }, 0.7f)
            .From(new { Scale = 0.7f })
            .Ease(Ease.SineOut)
            .Repeat()
            .Reflect();

            Winner.OnMessage(PhysicsBody.Message.Deactivate);
        }
예제 #8
0
파일: TmxMap.cs 프로젝트: Cryru/Emotion
        public TmxMap(XMLReader reader, string?filePath = null)
        {
            XMLReader?xMap = reader.Element("map");

            if (xMap == null)
            {
                return;
            }

            Version      = xMap.Attribute("version");
            TiledVersion = xMap.Attribute("tiledversion");

            Width           = xMap.AttributeInt("width");
            Height          = xMap.AttributeInt("height");
            TileWidth       = xMap.AttributeInt("tilewidth");
            TileHeight      = xMap.AttributeInt("tileheight");
            HexSideLength   = xMap.AttributeIntN("hexsidelength");
            Orientation     = xMap.AttributeEnum <Orientation>("orientation");
            StaggerAxis     = xMap.AttributeEnum <StaggerAxis>("staggeraxis");
            StaggerIndex    = xMap.AttributeEnum <StaggerIndex>("staggerindex");
            RenderOrder     = xMap.AttributeEnum <RenderOrder>("renderorder");
            NextObjectId    = xMap.AttributeIntN("nextobjectid");
            BackgroundColor = TmxHelpers.ParseTmxColor(xMap.Attribute("backgroundcolor"));

            Properties = TmxHelpers.GetPropertyDict(xMap.Element("properties"));

            foreach (XMLReader e in xMap.Elements("tileset"))
            {
                string?fileSource = e.Attribute("source");
                int    firstGid   = e.AttributeInt("firstgid");

                // Check if external file.
                if (!string.IsNullOrEmpty(fileSource))
                {
                    if (filePath != null)
                    {
                        string directory = AssetLoader.GetDirectoryName(filePath);
                        fileSource = AssetLoader.GetNonRelativePath(directory, fileSource);
                    }
                    var textAsset = Engine.AssetLoader.Get <TextAsset>(fileSource);
                    if (textAsset?.Content == null)
                    {
                        Engine.Log.Warning("Couldn't load external tileset.", MessageSource.TMX);
                        continue;
                    }

                    var       externalReader = new XMLReader(textAsset.Content);
                    XMLReader?tileSetElement = externalReader.Element("tileset");
                    if (tileSetElement == null)
                    {
                        continue;
                    }
                    Tilesets.Add(new TmxTileset(firstGid, tileSetElement));
                    continue;
                }

                Tilesets.Add(new TmxTileset(firstGid, e));
            }

            foreach (XMLReader e in xMap.Elements().Where(x => x.Name == "layer" || x.Name == "objectgroup" || x.Name == "imagelayer" || x.Name == "group"))
            {
                TmxLayer layer;
                switch (e.Name)
                {
                case "layer":
                    var tileLayer = new TmxLayer(e, Width, Height);
                    layer = tileLayer;
                    TileLayers.Add(tileLayer);
                    break;

                case "objectgroup":
                    var objectLayer = new TmxObjectLayer(e);
                    layer = objectLayer;
                    ObjectLayers.Add(objectLayer);
                    break;

                case "imagelayer":
                    var imageLayer = new TmxImageLayer(e);
                    layer = imageLayer;
                    ImageLayers.Add(imageLayer);
                    break;

                case "group":
                    var group = new TmxGroupedLayers(e, Width, Height);
                    layer = group;
                    Groups.Add(group);
                    break;

                default:
                    Engine.Log.Warning($"Unknown TMX layer type {e.Name}.", MessageSource.TMX);
                    continue;
                }

                Layers.Add(layer);
            }
        }
예제 #9
0
 public static int GetMask(ObjectLayers layer)
 {
     return(1 << LayerMask.NameToLayer(layer.ToString()));
 }
예제 #10
0
 void Awake()
 {
     instance = this;
 }
예제 #11
0
        public override void Added()
        {
            base.Added();

            Layer = ObjectLayers.JustAbove(ObjectLayers.Players);
        }