Exemple #1
0
        public void ProjectNew()
        {
            ActiveProject = new Project();

            UndoList = new Stack <IAction>();
            RedoList = new Stack <IAction>();

            ItemSavedOn = null;

            UpdateUndoRedoButtons();

            SetFileName(null);

            StickFigure defaultFig = new StickFigure();

            ActiveProject.Layers.Add(defaultFig.CreateDefaultLayer(0, 20, new LayerCreationArgs(0, "")));

            if (Form_Canvas != null)
            {
                Program.Form_Canvas.GLContext_Init();
                Program.Form_Canvas.CanvasForm_Resize(null, null);

                Program.Form_Canvas.Size = new Size(ActiveProject.Width, ActiveProject.Height);
            }

            if (MainTimeline != null)
            {
                MainTimeline.ClearSelection();
                MainTimeline.GLContext.Invalidate();
            }

            SetDirty(false);
        }
Exemple #2
0
        public void GLContext_MouseDown(object sender, MouseEventArgs e)
        {
            ActiveDragObject = null;
            Timeline timeline = Program.MainTimeline;

            if (timeline.SelectedLayer == null)
            {
                return;
            }
            if (timeline.SelectedKeyframe == null)
            {
                return;
            }

            Point location = RoundMousePos(UnprojectMousePos(e.Location));

            if (timeline.SelectedLayer.Data.GetType() == typeof(StickFigure) || timeline.SelectedLayer.Data.GetType() == typeof(CustomFigure))
            {
                StickFigurePair = StickFigure.FindJointStatePair(((StickFigure)timeline.SelectedLayer.Data).Root, ((StickFigure.State)timeline.SelectedKeyframe.State).Root, location);
            }

            ManipulateResult result = timeline.SelectedLayer.Data.TryManipulate(
                timeline.SelectedKeyframe.State, location, e.Button, ModifierKeys);

            if (result != null)
            {
                ActiveDragObject    = result.Target;
                ActiveDragParams    = result.Params;
                LastDragObject      = result.Target;
                ActiveDragPrevState = timeline.SelectedKeyframe.State.Copy();
            }

            Program.Form_Properties.UpdateStickFigurePanel();
        }
Exemple #3
0
        public StickEditorForm(StickFigure Figure, StickFigure.State State)
        {
            InitContext();

            FromProperties = true;

            ActiveFigure      = Figure;
            ActiveFigureState = State;
        }
Exemple #4
0
        // TODO: Replace font with something a little bigger
        public void Draw(SpriteBatch sb, Vector2 position, StickFigure figure)
        {
            sb.Draw(MainGame.tex_blank, position, null, Color.Black, 0f, Vector2.Zero, new Vector2(172, 32), SpriteEffects.None, 0f);
            sb.Draw(MainGame.tex_blank, position + Vector2.UnitY + Vector2.UnitX, null, figure.Color, 0f, Vector2.Zero, new Vector2(figure != null && figure.ScalarHealth > 0 ? figure.ScalarHealth * 170 : 0, 30), SpriteEffects.None, 0f);

            sb.Draw(MainGame.tex_head, position - Vector2.UnitX * 40 - Vector2.UnitY * 10, null, figure.Color, 0f, Vector2.Zero, Vector2.One * 0.55f, SpriteEffects.None, 0f);

            sb.Draw(MainGame.tex_heart, position + Vector2.UnitX * 20 + Vector2.UnitY * 35, null, Color.White, 0f, Vector2.Zero, Vector2.One * 0.33f, SpriteEffects.None, 0f);
            MainGame.DrawOutlineText(sb, MainGame.fnt_basicFont, "x" + this.Lives, position + Vector2.UnitX * 57 + Vector2.UnitY * 40, Color.White);
            sb.Draw(MainGame.tex_trapClosed, position + Vector2.UnitX * 96 + Vector2.UnitY * 37, null, Color.White, 0f, Vector2.Zero, Vector2.One * 1f, SpriteEffects.None, 0f);
            MainGame.DrawOutlineText(sb, MainGame.fnt_basicFont, "x" + figure.TrapAmmo, position + Vector2.UnitX * 128 + Vector2.UnitY * 40, Color.White);
        }
Exemple #5
0
        private void btn_openStickEditor_Click(object sender, EventArgs e)
        {
            StickEditorForm f = new StickEditorForm();

            if (f.ShowDialog() == DialogResult.OK)
            {
                txt_customFigPath.Text = "Custom figure created with Editor";

                CustomFigure      = f.CreatedFigure;
                CustomFigureState = f.CreatedFigureState;
            }
        }
Exemple #6
0
        private void GLContext_MouseDown(object sender, MouseEventArgs e)
        {
            if (ActiveManipMode == EditorManipMode.Pointer || ActiveManipMode == EditorManipMode.Move)
            {
                var pair   = StickFigure.FindJointStatePair(ActiveFigure.Root, ActiveFigureState.Root, e.Location);
                var result = ActiveFigure.TryManipulate(ActiveFigureState, e.Location, e.Button, ModifierKeys, !IKEnabled);

                if (result != null && pair != null)
                {
                    if (e.Button != MouseButtons.Right)
                    {
                        SelectedPair = pair;
                    }

                    if (ActiveManipMode == EditorManipMode.Move)
                    {
                        ActiveDragPair   = pair;
                        ActiveDragParams = result.Params;
                    }
                }
            }
            else if (ActiveManipMode == EditorManipMode.Add && SelectedPair != null)
            {
                StickFigure.Joint       joint = StickFigure.Joint.RelativeTo(SelectedPair.Item1, new PointF(-(SelectedPair.Item2.Location.X - e.X), -(SelectedPair.Item2.Location.Y - e.Y)));
                StickFigure.Joint.State state = StickFigure.Joint.State.RelativeTo(SelectedPair.Item2, new PointF(-(SelectedPair.Item2.Location.X - e.X), -(SelectedPair.Item2.Location.Y - e.Y)));

                SelectedPair = new Tuple <StickFigure.Joint, StickFigure.Joint.State>(joint, state);
            }
            else if (ActiveManipMode == EditorManipMode.Delete)
            {
                var pair   = StickFigure.FindJointStatePair(ActiveFigure.Root, ActiveFigureState.Root, e.Location);
                var result = ActiveFigure.TryManipulate(ActiveFigureState, e.Location, e.Button, ModifierKeys, !IKEnabled);

                if (result != null)
                {
                    StickFigure.Joint.State state = ((StickFigure.Joint.State)result.Target);
                    if (state.Parent == null)                     // No deleting everything allowed
                    {
                        return;
                    }

                    pair.Item1.Delete();
                    pair.Item2.Delete();

                    SelectedPair = null;
                }
            }

            GLContext.Invalidate();
        }
Exemple #7
0
        public void ProjectOpen(string filename)
        {
            ActiveFigure = new StickFigure();

            using (var reader = new BinaryReader(new FileStream(filename, FileMode.Open)))
            {
                UInt16 version = reader.ReadUInt16();
                ActiveFigure.Read(reader, version);
                reader.Close();
            }

            ActiveFigureState = (StickFigure.State)ActiveFigure.CreateRefState();

            UpdateSelection();

            GLContext.Invalidate();
        }
Exemple #8
0
        private void StickEditorForm_Load(object sender, EventArgs e)
        {
            GLContext_Init();

            if (!FromProperties)
            {
                ActiveFigure = new StickFigure();
                SelectedPair = null;

                int ID = 0;

                ActiveFigure.Root          = new StickFigure.Joint();
                ActiveFigure.Root.Location = new PointF(250, 300);
                var next = StickFigure.Joint.RelativeTo(ActiveFigure.Root, new PointF(0, -50));

                ActiveFigureState = (StickFigure.State)ActiveFigure.CreateRefState();
            }

            UpdateSelection();
        }
Exemple #9
0
        private void btn_stickApplyToFrameset_Click(object sender, EventArgs e)
        {
            if (Program.MainTimeline.SelectedFrameset == null)
            {
                return;
            }
            if (Program.MainTimeline.SelectedLayer.Data.GetType() != typeof(StickFigure))
            {
                return;
            }

            StickFigure fig = Program.MainTimeline.SelectedLayer.Data as StickFigure;

            foreach (Keyframe frame in Program.MainTimeline.SelectedFrameset.Keyframes)
            {
                fig.SetColor(frame.State, pnl_stickFigureColorImg.BackColor);
            }

            Program.MainTimeline.GLContext.Invalidate();
        }
Exemple #10
0
        public SingleMap()
        {
            world = new World(new Vector2(0, 9.8f));             // That'd be cool to have gravity as a map property, so you could play 0G levels

            testFigure  = new LocalPlayer(world, new Vector2(480 * MainGame.PIXEL_TO_METER, 480 * MainGame.PIXEL_TO_METER), Category.Cat1, Color.Red);
            dummyFigure = new StickFigure(world, new Vector2(150 * MainGame.PIXEL_TO_METER, 900 * MainGame.PIXEL_TO_METER), Category.Cat2, Color.Green);
            weapon      = new TestWeapon(world, new Vector2(640 * MainGame.PIXEL_TO_METER, 480 * MainGame.PIXEL_TO_METER));
            walls       = new List <Wall>();
            walls.Add(new Wall(world, 480 * MainGame.PIXEL_TO_METER, 700 * MainGame.PIXEL_TO_METER, 960 * MainGame.PIXEL_TO_METER, 32 * MainGame.PIXEL_TO_METER, 0.0f));
            walls.Add(new Wall(world, 16 * MainGame.PIXEL_TO_METER, 540 * MainGame.PIXEL_TO_METER, 32 * MainGame.PIXEL_TO_METER, 1080 * MainGame.PIXEL_TO_METER, 0.0f));
            walls.Add(new Wall(world, 960 * MainGame.PIXEL_TO_METER, 1040 * MainGame.PIXEL_TO_METER, 1920 * MainGame.PIXEL_TO_METER, 32 * MainGame.PIXEL_TO_METER, 0.0f));
            walls.Add(new Wall(world, 1500 * MainGame.PIXEL_TO_METER, 960 * MainGame.PIXEL_TO_METER, 870 * MainGame.PIXEL_TO_METER, 120 * MainGame.PIXEL_TO_METER, 0.0f));
            walls.Add(new Wall(world, 1450 * MainGame.PIXEL_TO_METER, 865 * MainGame.PIXEL_TO_METER, 248 * MainGame.PIXEL_TO_METER, 98 * MainGame.PIXEL_TO_METER, -(float)Math.PI / 6));
            walls.Add(new Wall(world, 1735 * MainGame.PIXEL_TO_METER, 840 * MainGame.PIXEL_TO_METER, 402 * MainGame.PIXEL_TO_METER, 176 * MainGame.PIXEL_TO_METER, 0.0f));
            walls.Add(new Wall(world, 1904 * MainGame.PIXEL_TO_METER, 540 * MainGame.PIXEL_TO_METER, 32 * MainGame.PIXEL_TO_METER, 1080 * MainGame.PIXEL_TO_METER, 0.0f));
            walls.Add(new Wall(world, 1859 * MainGame.PIXEL_TO_METER, 717 * MainGame.PIXEL_TO_METER, 109 * MainGame.PIXEL_TO_METER, 123 * MainGame.PIXEL_TO_METER, 0.0f));
            walls.Add(new Wall(world, 1600 * MainGame.PIXEL_TO_METER, 570 * MainGame.PIXEL_TO_METER, 122 * MainGame.PIXEL_TO_METER, 104 * MainGame.PIXEL_TO_METER, 0.0f));
            walls.Add(new Wall(world, 1320 * MainGame.PIXEL_TO_METER, 487 * MainGame.PIXEL_TO_METER, 113 * MainGame.PIXEL_TO_METER, 107 * MainGame.PIXEL_TO_METER, 0.0f));
            walls.Add(new Wall(world, 180 * MainGame.PIXEL_TO_METER, 300 * MainGame.PIXEL_TO_METER, 41 * MainGame.PIXEL_TO_METER, 370 * MainGame.PIXEL_TO_METER, 0.0f));

            bulletList = new List <Bullet>();
        }
Exemple #11
0
        private void btn_customFigBrowse_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Title  = "Open an Existing Custom Figure";
            dlg.Filter = "TISFAT Zero Figures|*.tzf";

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                txt_customFigPath.Text = dlg.FileName;

                CustomFigure = new StickFigure();

                using (var reader = new BinaryReader(new FileStream(dlg.FileName, FileMode.Open)))
                {
                    UInt16 version = reader.ReadUInt16();
                    CustomFigure.Read(reader, version);
                    reader.Close();
                }

                CustomFigureState = (StickFigure.State)CustomFigure.CreateRefState();
            }
        }
        private void BallManagerOnCollided(IGraphicalItem graphicalItem, IGraphicalItem otherGraphicalItem)
        {
            if (otherGraphicalItem is StickFigure)
            {
                StickFigure curStickFigure = otherGraphicalItem as StickFigure;

                if (graphicalItem is LionBall)
                {
                    if (!curStickFigure.ReverseGravity && PlaySounds)
                    {
                        flyAwaySound.Play();
                    }
                    curStickFigure.FillWithKnowledge();
                }
                else if (graphicalItem is Ball)
                {
                    CreateExplosion(curStickFigure.Position);
                    otherGraphicalItem.Destroy();
                    stickFigureManager.RemoveItem(otherGraphicalItem);
                }
                graphicalItem.Destroy();
                ballManager.RemoveItem(graphicalItem);
            }
        }
Exemple #13
0
        public StickLayer(string nom, StickFigure figure, Canvas aTheCanvas)
        {
            fig = figure;
            fig.parentLayer = this;

            //These are the default positions for keyframes.
            firstKF = 0;
            lastKF = 19;
            type = 1;

            keyFrames = new List<KeyFrame>();

            StickFrame first = new StickFrame(firstKF), last = new StickFrame(lastKF);

            foreach (StickJoint j in first.Joints)
                j.ParentFigure = fig;

            foreach (StickJoint j in last.Joints)
                j.ParentFigure = fig;

            keyFrames.Add(first);
            keyFrames.Add(last);

            theCanvas = aTheCanvas;

            tweenFig = new StickFigure(true, true);

            name = nom; //nomnomnom
        }
        public void AddStickFigure(int x, int y)
        {
            StickFigure figure = new StickFigure(new Vector2(x, y), new Vector2(0, 0), 25, 50, 0.4);

            stickFigureManager.AddItem(figure);
        }
Exemple #15
0
        private void btn_customFigBrowse_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Title = "Open an Existing Custom Figure";
            dlg.Filter = "TISFAT Zero Figures|*.tzf";

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                txt_customFigPath.Text = dlg.FileName;

                CustomFigure = new StickFigure();

                using (var reader = new BinaryReader(new FileStream(dlg.FileName, FileMode.Open)))
                {
                    UInt16 version = reader.ReadUInt16();
                    CustomFigure.Read(reader, version);
                    reader.Close();
                }

                CustomFigureState = (StickFigure.State)CustomFigure.CreateRefState();
            }
        }
Exemple #16
0
        private void btn_openStickEditor_Click(object sender, EventArgs e)
        {
            StickEditorForm f = new StickEditorForm();

            if(f.ShowDialog() == DialogResult.OK)
            {
                txt_customFigPath.Text = "Custom figure created with Editor";

                CustomFigure = f.CreatedFigure;
                CustomFigureState = f.CreatedFigureState;
            }
        }
Exemple #17
0
        public void ProjectNew()
        {
            ActiveProject = new Project();

            UndoList = new Stack<IAction>();
            RedoList = new Stack<IAction>();

            UpdateUndoRedoButtons();

            SetFileName(null);

            StickFigure defaultFig = new StickFigure();
            ActiveProject.Layers.Add(defaultFig.CreateDefaultLayer(0, 20, new LayerCreationArgs(0, "")));

            if (Form_Canvas != null)
            {
                Program.Form_Canvas.GLContext_Init();
                Program.Form_Canvas.CanvasForm_Resize(null, null);

                Program.Form_Canvas.Size = new Size(ActiveProject.Width, ActiveProject.Height);
            }

            if (MainTimeline != null)
            {
                MainTimeline.ClearSelection();
                MainTimeline.GLContext.Invalidate();
            }
        }
Exemple #18
0
 void Start()
 {
     main    = this;
     lRender = GetComponent <LineRenderer>();
 }