コード例 #1
0
        public override void Reload(UICollection uic, UIElementLayout uiel)
        {
            base.Reload(uic, uiel);
            var temp = uiel as UIButtonSaveLayout;

            if (temp.ButtonAnim_ClickState == null)
            {
                temp.ButtonAnim_ClickState = new ShapeAnimation();
            }
            if (temp.ButtonAnim_RestState == null)
            {
                temp.ButtonAnim_RestState = new ShapeAnimation();
            }
            if (temp.ButtonAnim_HoverState == null)
            {
                temp.ButtonAnim_HoverState = new ShapeAnimation();
            }

            temp.ButtonAnim_ClickState.ReloadTexture();
            temp.ButtonAnim_RestState.ReloadTexture();
            temp.ButtonAnim_HoverState.ReloadTexture();

            ButtonAnim_RestState  = temp.ButtonAnim_RestState;
            ButtonAnim_HoverState = temp.ButtonAnim_HoverState;
            ButtonAnim_ClickState = temp.ButtonAnim_ClickState;
        }
コード例 #2
0
        public void Reload()
        {
            try
            {
                _ButtonAnim_RestState = ShapeAnimation.animFromLuaInfo(ButtonAnim_RestState);
            }
            catch (Exception)
            {
                Console.WriteLine("Error in 'LuaUIButtonInfo' for 'ShapeAnimation.animFromLuaInfo(ButtonAnim_RestState)' ");
                _ButtonAnim_RestState = new ShapeAnimation();
            }

            try
            {
                _ButtonAnim_HoverState = ShapeAnimation.animFromLuaInfo(ButtonAnim_HoverState);
            }
            catch (Exception)
            {
                Console.WriteLine("Error in 'LuaUIButtonInfo' for 'ShapeAnimation.animFromLuaInfo(ButtonAnim_HoverState)' ");
                _ButtonAnim_HoverState = new ShapeAnimation();
            }

            try
            {
                _ButtonAnim_ClickState = ShapeAnimation.animFromLuaInfo(ButtonAnim_ClickState);
            }
            catch (Exception)
            {
                Console.WriteLine("Error in 'LuaUIButtonInfo' for 'ShapeAnimation.animFromLuaInfo(ButtonAnim_RestState)' ");
                _ButtonAnim_ClickState = new ShapeAnimation();
            }
        }
コード例 #3
0
    private bool LoadAnimationChunk()
    {
        m_currentAnimation = new ShapeAnimation(4);
        m_animations.Add(m_currentAnimation);

        m_chunkReader.ReadFloat();
        m_chunkReader.ReadFloat();
        LoadChunk();

        m_currentAnimation = null;
        return(true);
    }
コード例 #4
0
        static public void Start(Object obj, int width = 64, int height = 64)
        {
            widthHB  = 4;
            heightHB = 4;
            MapBuilder.controls.currentType = Scenes.Editor.MapEditorSub.MapEditorControls.controlType.HitboxEditor;
            bIsRunning     = true;
            hitboxWidth    = width;
            hitboxHeight   = height;
            saIndex        = 0;
            scale          = 8 - (width / 64 + 1);
            drawArea       = new Rectangle(0, 0, width * scale, height * scale);
            cameraPosition = Point.Zero;
            if (obj is BaseSprite)
            {
                if ((obj as BaseSprite).shapeHitBox.Count == 0)
                {
                    (obj as BaseSprite).shapeHitBox.Add(new List <Rectangle>());
                }
                hitboxList = (obj as BaseSprite).shapeHitBox[0];

                if (obj is BaseCharacter)
                {
                    sa = (obj as BaseCharacter).charAnimations[0];
                }
                else if (obj is BaseSprite && (obj as BaseSprite).baseAnimations.Count != 0)
                {
                    sa = (obj as BaseSprite).baseAnimations[0].Clone();
                }
                else if (obj is BaseSprite && (obj as BaseSprite).baseAnimations.Count == 0)
                {
                    (obj as BaseSprite).baseAnimations.Add(new ShapeAnimation());
                    sa = (obj as BaseSprite).baseAnimations[0].Clone();
                }
            }
            else if (obj is NPC)
            {
                hitboxList = (obj as NPC).baseCharacter.shapeHitBox[0];
                sa         = (obj as NPC).baseCharacter.charAnimations[0].Clone();
            }
            else if (obj is TileSource)
            {
                hitboxList = (obj as TileSource).tileHitBoxes;
                sa         = (obj as TileSource).tileAnimation;
            }



            onScreenBoxes.Clear();
            foreach (var item in hitboxList)
            {
                onScreenBoxes.Add(new Rectangle(item.X * scale, item.Y * scale, item.Width * scale, item.Height * scale));
            }
        }
コード例 #5
0
        public void Start(ShapeAnimation sa)
        {
            selectedAnimation = sa;

            if (sa.animationFrames.Count != 0)
            {
                frameWidth.Value  = sa.animationFrames[0].Width;
                frameHeight.Value = sa.animationFrames[0].Height;
            }

            numericUpDown1.Value = sa.frameInterval;

            Show();
        }
コード例 #6
0
 internal arrowInfo(Node pn, Node n, Node na)
 {
     loc = new Rectangle((n.coord.ToVector2() * 64).ToPoint(), new Point(64));
     if (na != null)
     {
         if (IsHorizontal(pn, n, na))
         {
             anim = horizontalL;
         }
         else if (IsVertical(pn, n, na))
         {
             anim = verticalL;
         }
         else if (IsLeftUp(pn, n, na))
         {
             anim = leftUpL;
         }
         else if (IsRightUp(pn, n, na))
         {
             anim = rightUpL;
         }
         else if (IsRightDown(pn, n, na))
         {
             anim = rightDownL;
         }
         else //if (IsLeftDown(pn, n, na))
         {
             anim = leftDownL;
         }
     }
     else //if (na == null)
     {
         if (isArrowLeft(pn, n))
         {
             anim = leftL;
         }
         else if (isArrowRight(pn, n))
         {
             anim = rightL;
         }
         else if (isArrowDown(pn, n))
         {
             anim = downL;
         }
         else
         {
             anim = upL;
         }
     }
 }
コード例 #7
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (seoColl != null && sheetTex != null)
            {
                generatedSources = new List <TileSource>();
                generatedObjects = new List <BaseSprite>();

                foreach (var item in seoColl.lseo)
                {
                    if (item.spriteObjectType == SpriteExportObject.spriteType.Tile)
                    {
                        TileSource ts = new TileSource();
                        ts.tileName                      = item.name;
                        ts.tileAnimation                 = new ShapeAnimation();
                        ts.tileAnimation.texFileLoc      = texLoc;
                        ts.tileAnimation.animationFrames = new List <Microsoft.Xna.Framework.Rectangle>(item.animationFrames);
                        ts.tileAnimation.ReloadTexture();
                        generatedSources.Add(ts);
                    }

                    if (item.spriteObjectType == SpriteExportObject.spriteType.Object)
                    {
                        BaseSprite ts = new BaseSprite();
                        ts.shapeName = item.name;
                        ShapeAnimation temp = new ShapeAnimation();
                        temp.texFileLoc      = texLoc;
                        temp.animationFrames = new List <Microsoft.Xna.Framework.Rectangle>(item.animationFrames);
                        temp.ReloadTexture();
                        ts.baseAnimations.Add(temp);
                        ts.spriteGameSize = new Microsoft.Xna.Framework.Rectangle(0, 0, item.width, item.height);
                        generatedObjects.Add(ts);
                        MapBuilder.gcDB.AddObject(ts);
                    }
                }

                foreach (var item in generatedSources)
                {
                    MapBuilder.gcDB.AddTile(item);
                }

                this.Close();
            }
        }
コード例 #8
0
    public ShapeAnimation(ShapeAnimation source, Transform topNode)
    {
        Length = source.Length;
        Nodes  = new ShapeAnimationNode[source.Nodes.Length];

        // Nodes cannot be shared because of their m_transform member
        for (int k = 0; k < source.Nodes.Length; k++)
        {
            var sourceNode = source.Nodes[k];
            var node       = new ShapeAnimationNode(sourceNode.Name, Length);
            node.Controllers = new ShapeAnimationController[sourceNode.Controllers.Length];
            for (int l = 0; l < sourceNode.Controllers.Length; l++)
            {
                // Controllers can be shared
                node.Controllers[l] = sourceNode.Controllers[l];
            }
            Nodes[k] = node;
        }
        SetTransforms(topNode);
    }
コード例 #9
0
        public override void Draw(SpriteBatch sb)
        {
            sb.End();
            sb.GraphicsDevice.SetRenderTarget(UIElementRender);
            sb.GraphicsDevice.Clear(Color.TransparentBlack);
            sb.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp);

            switch (currentState)
            {
            case ButtonState.NON_CLICKED:
                if (ButtonAnim_RestState == null)
                {
                    ButtonAnim_RestState = new ShapeAnimation();
                }
                ButtonAnim_RestState.Draw(sb, new Rectangle(Point.Zero, size));
                break;

            case ButtonState.CLICKED:
                if (ButtonAnim_ClickState == null)
                {
                    ButtonAnim_ClickState = new ShapeAnimation();
                }
                ButtonAnim_ClickState.Draw(sb, new Rectangle(Point.Zero, size));
                break;

            case ButtonState.HOVER:
                if (ButtonAnim_HoverState == null)
                {
                    ButtonAnim_HoverState = new ShapeAnimation();
                }
                ButtonAnim_HoverState.Draw(sb, new Rectangle(Point.Zero, size));
                break;

            default:
                break;
            }

            sb.End();
            sb.GraphicsDevice.SetRenderTarget(null);
        }
コード例 #10
0
        private float GetWheelsetRotation(ShapeAnimation animation)
        {
            float time = Time.time;

            return(2 * Mathf.PI * (time - (int)time));

/*
 *              foreach (ShapeAnimationNode node in animation.Nodes)
 *              {
 *                      if (node.Name.StartsWith("WHEELSETTRANSFORM"))
 *                      {
 *                              foreach (Bogie bogie in m_bogies)
 *                              {
 *                                      float angle;
 *                                      if (bogie.GetWheelsetRotation(node.Name, out angle))
 *                                      {
 *                                              return angle;
 *                                      }
 *                              }
 *                      }
 *              }
 *              return 0;
 */
        }
コード例 #11
0
 internal portraitFrame(ShapeAnimation portrait, Rectangle r)
 {
     this.portrait = portrait;
     this.position = new Rectangle(r.X, r.Y, r.Width, r.Height);
 }
コード例 #12
0
 internal void AssignBaseButtonAnimations(params ShapeAnimation[] sas)
 {
     ButtonAnim_RestState  = sas[0];
     ButtonAnim_HoverState = sas[1];
     ButtonAnim_ClickState = sas[2];
 }
コード例 #13
0
        public static void Test()
        {
            NLua.Lua state = new NLua.Lua();

            NLua.Lua state2 = new NLua.Lua();

            someData sd = new someData();

            sd.ID = 25;
            sd.sList.AddRange(new String[] { "this", " is", " a", " test", " list" });
            luaData ld = new luaData(sd);


            //var test = state.DoString("return 10 + 3*(5 + 2)")[0];
            //var type = test.GetType();

            //int value = 6;
            //state["test"] = value;
            //var result = state.DoString("return test*3+(test-3)")[0];

            //state.DoString(@"
            // function ScriptFunc (val1, val2)
            //     val1=val1+2
            //     val2=val2+3
            //     return val1, val2
            //  end");

            //var scriptFunc = state["ScriptFunc"] as NLua.LuaFunction;
            //var res = scriptFunc.Call(3, 5);

            testClass tc = new testClass("Some test string here");

            tc.list.Add(25);
            state["provision"] = "Random piece of information";



            testClass tc2 = new testClass("Indirect summon");

            tc2.data = ld;
            tc2.ProvideInfoToLua(state);
            //state["testObj"] = tc;

            state.LoadCLRPackage();
            // state.DoString(@" import ('The betrayer', 'TBAGW.Utilities')
            //   import ('System.Web')
            //    import ('System')");

            // var testStringFromObject = state.DoString("return TestObject.testList[0]")[0];
            // var elementType = testStringFromObject.GetType();
            // testClass testObjFromLUA = state.DoString("return TestObject")[0] as testClass;
            //bool bWhat = testObjFromLUA.GetType() == tc.GetType();

            state.DoString("print(\"Hello World\")");

            System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
            ofd.Filter           = "LUA files (*.lua)|*.lua";
            ofd.InitialDirectory = Game1.rootContent;
            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                state = new NLua.Lua();
                state.LoadCLRPackage();
                state.DoFile(ofd.FileName);
                var time = System.IO.File.GetLastWriteTime(ofd.FileName);
            }
            //var statsTest = ((state["generateSomeStats"] as NLua.LuaFunction).Call()[0] as LuaStatEdit).ExtractStatChart();

            //BaseSprite bs = new BaseSprite();
            //bs.position = new Vector2(136, 2556);
            //if (Scenes.Editor.MapBuilder.loadedMap != null)
            //{
            //    bs.UpdatePosition();
            //}
            // List<List<Object>> luaStuff = new List<List<object>>();
            //var ttt = (state["save"] as NLua.LuaFunction).Call()[0].GetType();
            (state["save"] as NLua.LuaFunction).Call();
            var st = LuaSaveData.getGlobalData("My Collection", "luaStuff");

            (state["loadProcess"] as NLua.LuaFunction).Call();
            //var dabdab = ((state["getShapeData"] as NLua.LuaFunction).Call(bs));
            //  NLua.LuaFunction savedFunction = state["e1.Test"] as NLua.LuaFunction;
            uic = ((state["createUI"] as NLua.LuaFunction).Call()[0] as LuaUICollection).ConvertFromLua(state);
            goto skip;
            var luaRect = ShapeAnimation.animFromLuaInfo(((state["generateAnimation"] as NLua.LuaFunction).Call()[0] as LuaShapeAnimationInfo));
            var resldo  = (state["returnLuaSpecificData"] as NLua.LuaFunction).Call()[0];

            NLua.LuaTable lt = (state["returnLuaSpecificData"] as NLua.LuaFunction).Call()[0] as NLua.LuaTable;
            (state["GenerateSomeStuff"] as NLua.LuaFunction).Call();
            ListDataProvider.setLuaData(state);
            (state["publicStaticCall"] as NLua.LuaFunction).Call();
            (state["internalStaticCall"] as NLua.LuaFunction).Call();
            state["testObj"] = tc;
            var ele2                     = (state["attempt"] as NLua.LuaFunction).Call()[0];
            var returnedData             = (state["returnData"] as NLua.LuaFunction).Call()[0];
            var oldProvision             = state["provision"];
            var value2                   = state["testObj.i"];
            var function                 = state["MyFunc"] as NLua.LuaFunction;
            var funcRes                  = function.Call(state["testObj.i"])[0];
            var tableResult              = (state["returnTable"] as NLua.LuaFunction).Call()[0];
            var bCompare1                = tableResult.GetType() == typeof(NLua.LuaTable);
            var tableToList              = LUAUtilities.LUATableToListUtility(typeof(testClass), tableResult as NLua.LuaTable).Cast <testClass>().ToList();
            var tableToListGenericObject = LUAUtilities.LUATableToListUtility(typeof(testClass), tableResult as NLua.LuaTable);
            var listType                 = tableToList.GetType();
            var listTypeGO               = tableToListGenericObject.GetType();



            state = new NLua.Lua();
            state.LoadCLRPackage();
            state.DoFile(ofd.FileName);
            List <testClass> tcl = new List <testClass>();

            tcl.Add(new testClass(""));
            tcl.Last().i = 25;
            tcl.Add(new testClass(""));
            tcl.Last().i = 0;
            tcl.Add(new testClass(""));
            tcl.Last().i = 10;
            foreach (var item in tcl)
            {
                (state["setStuff"] as NLua.LuaFunction).Call(item);
            }

            tcl = LUAUtilities.LUATableToListUtility(typeof(testClass), (state["doStuff"] as NLua.LuaFunction).Call()[0] as NLua.LuaTable).Cast <testClass>().ToList();
            skip : { }
            bDoTest = false;
        }
コード例 #14
0
 internal arrowInfo(ShapeAnimation sa, Rectangle l)
 {
     anim = sa;
     loc  = l;
 }