コード例 #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
ファイル: Layers.cs プロジェクト: Aspekt1024/Hexapawn
 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);
        }