Example #1
0
        private void CreateNew(int a_nLocX)
        {
            Sprite sp = new Sprite();
            sp.Name = "Obstacle";
            sp.LocZ = 5;
            //TODO: new animation system
            MemberSpriteBitmap mb = (MemberSpriteBitmap)EndogineHub.Instance.CastLib.GetOrCreate("asteroid01");
            //mb.NumFramesPerAxis = new EPoint(7,6);
            sp.Member = mb;

            if (a_nLocX <= 0)
                a_nLocX = GameMain.Instance.CaveWalls.GetMaxX();
            float[] walls = GameMain.Instance.CaveWalls.GetWallsYOnX(a_nLocX);

            Random rnd = new Random();
            sp.Loc = new EPointF(a_nLocX, (walls[1]-walls[0])*(float)rnd.NextDouble()+walls[0]);
            //sp.AutoAnimator.StepSize = 0.1f;
            sp.Scaling = new EPointF(0.3f,0.3f);

            BhReportWhenOutside bh = new BhReportWhenOutside();
            sp.AddBehavior(bh);
            bh.Outside+=new CaveHunter.BhReportWhenOutside.OutsideDelegate(bh_Outside);

            m_obstacles.Add(sp);
        }
Example #2
0
 public Score()
 {
     this.m_sp = new Sprite();
     this.m_sp.SetGraphics("ScoreText");
     this.m_sp.Color = GameMain.Instance.m_clrOffwhite;
     this.m_sp.Loc = new EPointF(188,17);
 }
Example #3
0
        public Player(PlayArea a_playArea, Hashtable a_htDefaultKeys)
        {
            m_playArea = a_playArea;
            MemberName = "Cross";

            m_arrow = new Sprite();
            m_arrow.Parent = this;
            m_arrow.Name = "Arrow";
            m_arrow.MemberName = "Cross";
            m_arrow.Member.CenterRegPoint();
            m_arrow.Member = m_arrow.Member;
            m_arrow.LocZ = 60;
            //m_arrow.Loc = m_playArea.Grid.GetGfxLocFromGridLoc(m_playArea.Grid.GetGridStartLoc());

            if (a_htDefaultKeys.Count == 0)
            {
                a_htDefaultKeys = new Hashtable();
                a_htDefaultKeys.Add("left", Keys.Left);
                a_htDefaultKeys.Add("right", Keys.Right);
                a_htDefaultKeys.Add("up", Keys.Up);
                a_htDefaultKeys.Add("shoot", Keys.Down);
            }
            m_keysSteering = new KeysSteering(a_htDefaultKeys);
            m_keysSteering.AddPair("left", "right");
            m_keysSteering.KeyEvent += new Endogine.KeyEventHandler(m_keysSteering_KeyEvent);

            m_score = new Score();

            m_spTarget = new Sprite();
            m_spTarget.MemberName = "Cross";
            m_spTarget.CenterRegPoint();
            m_spTarget.Blend = 50;
            m_spTarget.Parent = m_playArea;
            m_spTarget.LocZ = 50;
        }
Example #4
0
 private void m_btnClose_MouseEvent(Sprite sender, System.Windows.Forms.MouseEventArgs e, MouseEventType t)
 {
     if (t == Sprite.MouseEventType.Click)
     {
         ((Form)Parent).Close();
     }
 }
Example #5
0
 public LivesLeft()
 {
     this.m_sp = new Sprite();
     this.m_sp.SetGraphics("Stats");
     this.m_sp.Color = GameMain.Instance.m_clrOffwhite;
     this.m_sp.Loc = new EPointF(96,448);
 }
Example #6
0
        public Form()
        {
            this.m_bNoScalingOnSetRect = true;
            Name = "Form";

            m_frame = new Frame();
            m_frame.Parent = this;
            m_frame.Ink = RasterOps.ROPs.D3DTest2;
            //MemberSpriteBitmap mb = (MemberSpriteBitmap)m_endogine.CastLib.GetOrCreate("Button2Up");
            //m_frame.Member = mb;
            m_frame.MemberName = "Button2Up";
            m_frame.LocZ = 0;
            m_frame.MouseActive = true; //as to not let mouse clicks fall through to sprites behind

            m_dragbar = new Dragbar();
            m_dragbar.LocZ = 1;
            m_dragbar.Parent = this;

            m_resizeCorner = new Sprite();
            m_resizeCorner.Parent = this;
            m_resizeCorner.LocZ = 1;
            m_resizeCorner.Name = "ResizeCorner";
            m_resizeCorner.MemberName = "Button2Up";
            //m_resizeCorner.Member = mb;
            m_resizeCorner.Ink = RasterOps.ROPs.BgTransparent;
            m_resizeCorner.SourceRect = new ERectangle(0,0,15,15);
            m_resizeCorner.MouseActive = true;
            m_resizeCorner.MouseEvent+=new MouseEventDelegate(m_resizeCorner_MouseEvent);
        }
Example #7
0
 private void m_frame_MouseEvent(Sprite sender, System.Windows.Forms.MouseEventArgs e, MouseEventType t)
 {
     if (t == Sprite.MouseEventType.StillDown)
     {
         EPointF pntDiff = new EPointF(e.X-m_frame.MouseLastLoc.X, e.Y-m_frame.MouseLastLoc.Y);
         this.Parent.Move(pntDiff);
     }
 }
Example #8
0
        public PlayerBall()
        {
            this.MouseActive = true;
            this.MouseEvent+=new MouseEventDelegate(PlayerBall_MouseEvent);

            forceMarker = new Sprite();
            forceMarker.LocZ = 15;
            forceMarker.Ink = RasterOps.ROPs.AddPin;
        }
Example #9
0
 public bool CheckCollision(Sprite sp)
 {
     foreach (Sprite wall in m_wallSprites)
     {
         if (wall.GetCollisionPoint(sp) != null)
             return true;
     }
     return false;
 }
Example #10
0
 public bool CheckCollision(Sprite sp)
 {
     foreach (Sprite obstacle in m_obstacles)
     {
         if (obstacle.GetCollisionPoint(sp) != null)
             return true;
     }
     return false;
 }
Example #11
0
 private void btnChangeSize_MouseEvent(Sprite sender, System.Windows.Forms.MouseEventArgs e, Endogine.Sprite.MouseEventType t)
 {
     //Mouse down on size change button
     if (t == Endogine.Sprite.MouseEventType.Down)
     {
         if (m_psys==null)
             return;
         m_psys.ChangeSizes();
     }
 }
Example #12
0
        public bool CheckCollision(Sprite sp)
        {
            if (this.m_bExploding)
                return false; //can't be hit twice.

            EPointF pntHit = this.GetCollisionPoint(sp);
            if (pntHit == null)
                return false;
            this.Explode();
            return true;
        }
Example #13
0
        public bool CheckCollision(Sprite sp)
        {
            if (m_nExplodeCnt > 0)
                return false; //can't be hit again while burning

            EPointF pntHit = this.GetCollisionPoint(sp);
            if (pntHit == null)
                return false;
            this.Explode();
            return true;
        }
Example #14
0
        private void PlayerBall_MouseEvent(Sprite sender, System.Windows.Forms.MouseEventArgs e, MouseEventType t)
        {
            if (t == Sprite.MouseEventType.Down)
            {
                forceMarker.Visible = true;
            }
            else if (t == Sprite.MouseEventType.StillDown)
            {
                MemberSpriteBitmap mb = forceMarker.Member;
                if (mb!=null)
                    mb.Dispose();

                //this.MouseDownLoc.X, this.MouseDownLoc.Y
                ERectangleF rctLine = ERectangleF.FromLTRB(this.Loc.X, this.Loc.Y, this.MouseLastLoc.X, this.MouseLastLoc.Y);
                forceVector = rctLine.Size;

                if (rctLine.Width != 0 && rctLine.Height != 0)
                {
                    Bitmap bmp = new Bitmap((int)Math.Abs(rctLine.Width)+1, (int)Math.Abs(rctLine.Height)+1, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
                    Graphics g = Graphics.FromImage(bmp);

                    ERectangleF rctOrigo = rctLine.Copy();
                    rctOrigo.MakeTopLeftAtOrigo();

                    Pen pen = new Pen(Color.Red, 2);
                    g.DrawLine(pen, rctOrigo.X, rctOrigo.Y, rctOrigo.X+rctOrigo.Width, rctOrigo.Y+rctOrigo.Height);
                    g.Dispose();

                    EPointF locOffset = new EPointF();
                    if (rctOrigo.Width < 0)
                        locOffset.X = rctOrigo.Width;
                    if (rctOrigo.Height < 0)
                        locOffset.Y = rctOrigo.Height;

                    mb = new MemberSpriteBitmap(bmp);
                    forceMarker.Member = mb;
                    forceMarker.Loc = this.Loc + locOffset;
                }
                else
                    forceMarker.Member = null;
            }
            else if (t == Sprite.MouseEventType.UpOutside || t == Sprite.MouseEventType.Click)
            {
                this.Velocity = forceVector*-0.1f;

                forceMarker.Visible = false;
                MemberSpriteBitmap mb = forceMarker.Member;
                if (mb!=null)
                {
                    forceMarker.Member = null;
                    mb.Dispose();
                }
            }
        }
Example #15
0
        private void bh_Outside(Sprite sp)
        {
            m_wallSprites.Remove(sp);
            sp.Dispose();

            if (sp.Name == "Ceiling")
            {
                for (int i = 0; i < m_nTileWidth; i++)
                    m_locYPairs.RemoveAt(0);

                CreateNewTiles((int)((Sprite)m_wallSprites[m_wallSprites.Count-1]).LocX + this.m_nTileWidth);
            }
        }
Example #16
0
 public bool CheckCollision(Sprite sp)
 {
     for (int i = this._invaders.Count - 1; i >= 0; i--)
     {
         Invader inv = this._invaders[i];
         if (inv.GetCollisionPoint(sp) != null)
         {
             inv.Explode();
             return true;
         }
     }
     return false;
 }
Example #17
0
        public void ShowProperties(Sprite a_sp)
        {
            if (a_sp == null)
                return;
            m_sp = a_sp;

            this.Text = this.m_sp.GetSceneGraphName() + " Properties";
            //this.Text = m_sp.Name + " Properties";

            this.propertyGrid1.SelectedObject = a_sp;

            //			System.Windows.Forms.Button btn = new System.Windows.Forms.Button();
            int nNumBh = this.m_sp.GetNumBehaviors();
            this.btnBehaviors.Text = "Behaviors ("+nNumBh+") ...";
            //this.btnBehaviors.Top = this.propertyGrid1.Bottom+10;
            //this.btnBehaviors.Click+=new EventHandler(btn_Click);
            //this.btnBehaviors.Width = 100;
            //this.Controls.Add(this.btnBehaviors);
        }
Example #18
0
        public AStarViz(AStarSearch astar)
        {
            this.m_astar = astar;
            this.m_astar.SearchedCoordinate+=new Endogine.AStar.AStarSearch.SearchDelegate(m_astar_SearchedCoordinate);
            this.m_astar.ChangedStartCoordinate+=new Endogine.AStar.AStarSearch.SearchDelegate(m_astar_ChangedStartCoordinate);
            this.m_astar.ChangedGoalCoordinate+=new Endogine.AStar.AStarSearch.SearchDelegate(m_astar_ChangedGoalCoordinate);
            this.m_astar.SearchFinished+=new Endogine.AStar.AStarSearch.SearchDelegate(m_astar_SearchFinished);
            this.m_astar.SearchStarted+=new Endogine.AStar.AStarSearch.SearchDelegate(m_astar_SearchStarted);
            this.m_astar.ChangedAcceptableGoals+=new Endogine.AStar.AStarSearch.SearchDelegate(m_astar_ChangedAcceptableGoals);

            this.m_sp = new Sprite();
            this.m_sp.Name = "Map";
            this.m_sp.Parent = EH.Instance.Stage.RootSprite;
            this.m_sp.Scaling = new EPointF(2,2);
            this.m_sp.LocZ = 5001;
            this.m_sp.Ink = RasterOps.ROPs.AddPin;

            EH.Instance.EnterFrameEvent+=new EnterFrame(Instance_EnterFrameEvent);
        }
Example #19
0
        private void Setup()
        {
            Random rnd = new Random();
            //Console.WriteLine(this.Note.ToString());

            //this.Loc = new EPointF((this.Note-36)*30+80, rnd.Next(400));

            this._spTimer = new Sprite(false);
            this._spTimer.Parent = this;
            this._spTimer.MemberName = "BallGreen";
            this._spTimer.CenterRegPoint();
            //			this._spTimer.Scaling = new EPointF(2,2);

            this._spHit = new Sprite(false);
            this._spHit.LocZ = 2;
            this._spHit.MemberName = "BallRed";
            this._spHit.CenterRegPoint();
            this._spHit.Parent = this;
        }
Example #20
0
        public PlayArea()
        {
            //this.m_bNoScalingOnSetRect = true;
            m_spBg = new Sprite();
            m_spBg.Name = "Bg";
            m_spBg.MemberName = "PlayArea";
            m_spBg.Parent = this;
            m_spBg.RegPoint = new EPoint(30,30);

            m_spBgFill = new Sprite();
            m_spBgFill.Parent = this;
            m_spBgFill.Name = "BgFill";

            m_pathCalc = new PathCalc(this);
            Grid = new Grid(this);

            m_aCollisionLines = new ArrayList();
            EPointF pntTopLeft = Grid.GetGfxLocFromGridLoc(new EPointF(-1f,-0.0f));
            EPointF pntBottomRight = Grid.GetGfxLocFromGridLoc(new EPointF(Grid.GridSize.Width+0.5f,Grid.GridSize.Height));

            //first line is ceiling (where balls stick)
            m_aCollisionLines.Add(ERectangleF.FromLTRB(pntTopLeft.X,pntTopLeft.Y,pntBottomRight.X,pntTopLeft.Y));
            m_aCollisionLines.Add(ERectangleF.FromLTRB(pntTopLeft.X,pntTopLeft.Y,pntTopLeft.X,pntBottomRight.Y));
            m_aCollisionLines.Add(ERectangleF.FromLTRB(pntBottomRight.X,pntTopLeft.Y,pntBottomRight.X,pntBottomRight.Y));

            m_aPlayers = new ArrayList();
            AddPlayer(new Hashtable());

            Hashtable htKeysForPlayer2 = new Hashtable();
            htKeysForPlayer2.Add("left", System.Windows.Forms.Keys.A);
            htKeysForPlayer2.Add("right", System.Windows.Forms.Keys.D);
            htKeysForPlayer2.Add("up", System.Windows.Forms.Keys.W);
            htKeysForPlayer2.Add("shoot", System.Windows.Forms.Keys.S);
            AddPlayer(htKeysForPlayer2);
            //TODO: A fun cooperative mode would be to force players to take turns.

            //TODO: write a main game class which manages levels and multiple playAreas.
            m_level = new LevelManager(this);
            NextLevel();
        }
Example #21
0
        public GameMain()
        {
            Instance = this;

            string path = AppSettings.Instance.GetPath("Media") + "SpaceInv";
            AppSettings.Instance.AddPath("Media", path);
            PicRef.ScanDirectory(path);

            this.m_clrOffwhite = System.Drawing.Color.FromArgb(214,181,140);

            this.m_interfaceSprites = new ArrayList();

            this.m_score = new Score();

            this.m_livesLeft = new LivesLeft();

            Sprite sp = new Sprite();
            sp.SetGraphics("Screen");
            sp.LocZ = 500;
            sp.Ink = RasterOps.ROPs.AddPin;
            this.m_interfaceSprites.Add(sp);

            this.AddColorizers();

            this.m_covers = new ArrayList();
            Cover cover;
            for (int nCoverNum = 0; nCoverNum < 4; nCoverNum++)
            {
                cover = new Cover();
                cover.Loc = new EPointF(170 + 90 + (nCoverNum-1)*90,369);
                this.m_covers.Add(cover);
            }

            ERectangleF rctPlayArea = ERectangleF.FromLTRB(155,20,550,400); //new ERectangleF(145,10,350,200); //155 550
            this.m_invadersGrid = new InvadersGrid();

            //ERectangleF rctPlayerConstraints = rctPlayArea+ERectangleF.FromLTRB(-10,0,-55,0);
            this.m_player = new Player();
        }
Example #22
0
        public DrumForm()
        {
            if (Endogine.Audio.SoundManager.DefaultSoundManager == null)
            {
                throw new Exception("No sound system .dll found!");
            }
            this.Rect = new ERectangleF(0,0,600,150);
            this.m_pntGridCellSize = new EPoint(35,40);
            this.m_pntGridStart = new EPointF(10,50);
            this.MouseActive = true;

            this.m_tracks = new Track[2];

            string[] aSounds = new string[]{"drumsnare.wav", "drumbass.wav"};
            for (int nChannel = 0; nChannel < aSounds.Length; nChannel++)
            {
                Track track = new Track(aSounds[nChannel], m_nNumNotes, this.m_pntGridCellSize);
                track.Parent = this;
                track.Loc = new EPointF(0,nChannel*this.m_pntGridCellSize.Y)+m_pntGridStart;
                this.m_tracks[nChannel] = track;
                //track.Visible=false;
            }

            this.m_tracks[0].LoadPattern(new int[]{0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0});
            this.m_tracks[1].LoadPattern(new int[]{1,0,1,0,0,0,1,0,1,0,1,0,0,0,0,0});

            this.m_spPlaybackHead = new Sprite();
            this.m_spPlaybackHead.MemberName = "Cross";
            this.m_spPlaybackHead.CenterRegPoint();
            this.m_spPlaybackHead.Parent = this;
            this.m_spPlaybackHead.Loc = m_pntGridStart;

            this.m_timer = new Timer(new TimerCallback(this.Tick), null, 0, 125);

            this._listener = new Endogine.Audio.Listener();

            this._pk = new PlayKeyboard();
        }
Example #23
0
        private void CreateNewTiles(int a_nLocX)
        {
            //use perlin noise to generate wall structure
            ArrayList aNoise = new ArrayList();
            for (int x = 0; x < m_nTileWidth; x++)
                aNoise.Add(0f);
            m_noise.Offset = new EPointF(a_nLocX, 0);
            m_noise.FillArray(aNoise);

            PointF[] aPoints1 = new PointF[m_nTileWidth];
            PointF[] aPoints2 = new PointF[m_nTileWidth];
            for (int x = 0; x < m_nTileWidth; x++)
            {
                m_fCaveHeight*=0.9997f;
                float fAllowedY = m_rctPlayArea.Height - m_fCaveHeight;
                m_fMidY=((float)aNoise[x])*fAllowedY;

                float[] yPair = new float[]{m_fMidY, m_fMidY+m_fCaveHeight};

                aPoints1[x] = new PointF(x,yPair[0]);
                aPoints2[x] = new PointF(x,yPair[1]);

                m_locYPairs.Add(x+a_nLocX, yPair);
            }

            ArrayList aBothTileLines = new ArrayList();
            aBothTileLines.Add(new TileLines(aPoints1));
            aBothTileLines.Add(new TileLines(aPoints2));

            for (int i = 0; i < 2; i++)
            {
                TileLines tileLines = (TileLines)aBothTileLines[i];
                Bitmap bmp;
                Graphics g;
                float fYDiff = tileLines.MaxY-tileLines.MinY+1;
                bmp = new Bitmap(m_nTileWidth,(int)fYDiff);
                g = Graphics.FromImage(bmp);
                g.FillRectangle(new SolidBrush(Color.Black), 0,0,bmp.Width,bmp.Height);
                //g.DrawLines(new Pen(Color.White, 2), tileLines.Points);
                //create polygon from lines:
                PointF[] polygon = tileLines.GetPolygon(i == 1);
                g.FillPolygon(new SolidBrush(Color.White), polygon);
                g.Dispose();

                MemberSpriteBitmap mb = new MemberSpriteBitmap(bmp);
                Sprite sp = new Sprite();
                sp.Member = mb;
                sp.LocX = a_nLocX;
                sp.LocY = tileLines.MinY;
                if (i == 0)
                    sp.Name = "Ceiling";
                else
                    sp.Name = "Floor";

                BhReportWhenOutside bh = new BhReportWhenOutside();
                sp.AddBehavior(bh);
                bh.Outside+=new CaveHunter.BhReportWhenOutside.OutsideDelegate(bh_Outside);

                m_wallSprites.Add(sp);

                Sprite spFill = new Sprite();
                spFill.MemberName = "BG1";
                if (i == 0)
                    spFill.Rect = new ERectangleF(sp.LocX, m_rctPlayArea.Top, this.m_nTileWidth, sp.Rect.Top);
                else
                    spFill.Rect = new ERectangleF(sp.LocX, sp.Rect.Bottom, this.m_nTileWidth, m_rctPlayArea.Bottom-sp.Rect.Bottom);
                bh = new BhReportWhenOutside();
                spFill.AddBehavior(bh);
                bh.Outside+=new CaveHunter.BhReportWhenOutside.OutsideDelegate(bh_Outside);

                m_wallSprites.Add(spFill);
            }
        }
Example #24
0
 public virtual Sprite Copy()
 {
     Sprite sp = new Sprite();
     this.CopyTo(sp);
     return sp;
 }
Example #25
0
 public virtual void CopyTo(Sprite sp)
 {
     //TODO: use serialization instead!
     //sp.EndogineHub = this.EndogineHub;
     sp.Parent = this.Parent;
     sp.Blend = this.Blend;
     sp.Color = this.Color;
     sp.Cursor = this.Cursor;
     sp.DrawToSprite = this.DrawToSprite;
     sp.Ink = this.Ink;
     sp.Loc = this.Loc;
     sp.LocZ = this.LocZ;
     sp.MouseActive = this.MouseActive;
     sp.MousePassButton = this.MousePassButton;
     sp.Name = this.Name;
     sp.PassMouseEvent = this.PassMouseEvent;
     sp.PicRef = this.PicRef;
     sp.RegPoint = this.RegPoint;
     sp.Rotation = this.Rotation;
     sp.Scaling = this.Scaling;
     //TODO: some other stuff
     sp.Visible = this.Visible;
 }
Example #26
0
 public override void CopyTo(Sprite sp)
 {
     base.CopyTo(sp);
     ParallaxLayer layer = (ParallaxLayer)sp;
     layer.ScrollFactor = this.ScrollFactor;
 }
Example #27
0
        public virtual void EnterFrame()
        {
            if (EnterFrameEvent!=null)
                EnterFrameEvent();

            m_renderStrategy.EnterFrame();

            m_bLooping = true;

            Sprite[] sprites = new Sprite[this._slChildrenLocZSorted.Count];
            for (int i=sprites.Length-1;i>=0;i--)
            {
                Sprite sp = (Sprite)this._slChildrenLocZSorted.GetByIndex(i);
                sprites[i] = sp;
            }
            foreach (Sprite sp in sprites)
            {
                if (sp.Disposing)
                    continue;
                sp.EnterFrame();
            }
            m_bLooping = false;

            foreach (Sprite sp in m_aChildrenToRemove)
                RemoveChild(sp);
            m_aChildrenToRemove.Clear();
        }
Example #28
0
 private void bh_Outside(Sprite sp)
 {
     m_obstacles.Remove(sp);
     sp.Dispose();
     CreateNew(-1);
 }
Example #29
0
        public EPointF ConvParentLocToDrawLoc(EPointF a_pntLoc, Sprite a_spDraw)
        {
            if (m_spParent == null || (m_spParent!=null && m_spParent == a_spDraw))
                return a_pntLoc;

            a_pntLoc = m_spParent.ConvSrcLocToParentLoc(a_pntLoc);
            return m_spParent.ConvParentLocToDrawLoc(a_pntLoc, a_spDraw);
        }
Example #30
0
        public override void RemoveChild(Sprite a_sp)
        {
            Invader inv = (Invader)a_sp;
            if (this._invaders.Contains(inv))
            {
                this._invaders.Remove(inv);

                //also remove from m_columnSortedInvaders:
                for (int n = this._columnSortedInvaders.Count-1; n >= 0; n--)
                {
                    SortedList<int, Invader> slCol = this._columnSortedInvaders.Values[n];
                    int nIndex = slCol.IndexOfValue(inv);
                    if (nIndex>=0)
                    {
                        slCol.RemoveAt(nIndex);
                        if (slCol.Count == 0)
                            this._columnSortedInvaders.RemoveAt(n);
                        break;
                    }
                }
            }
            base.RemoveChild (a_sp);
        }