public override void LoadContent() { _charTex = UniversalVariables.content.Load <Texture2D>("SpriteSheet Char"); _char = new Character("Char", new Vector2(0, 0), _charTex, Color.White, SpriteEffects.None, 0, new Vector2(19, 29), .5f, "Standing", 0, true, AddCharAnims(), true, new List <GameAttribute>(), new List <Perk>(), new CharacterInventory(), 5f); base.LoadContent(); cam = new GameCam(_char, new Rectangle(250, 0, UniversalVariables.graphics.PreferredBackBufferWidth, UniversalVariables.graphics.PreferredBackBufferHeight)); _char.CurrentAnimation = "Standing"; mp = new Map(UniversalVariables.spriteBatch); Tiles = UniversalVariables.content.Load <Texture2D>("SpriteSheet Tiles"); GenerateMap(); Mous = new CompMouse("mouse", UniversalVariables.content.Load <Texture2D>("SpriteSheet Misc"), CreateMouseAnimation()); Mous.CurrentAnimation = "neutral"; MagMan = new MagicManager(UniversalVariables.content.Load <Texture2D>("SpriteSheet Magic"), new Rectangle(0, 14, 6, 6), new Rectangle(0, 0, 12, 12), new Rectangle(0, 12, 2, 2)); GenerateBaseEntityList(); Interface.Add(0, Mous); MagMan.AddPrimalShapes(); }
/// <summary> /// Update based on input /// </summary> /// <param name="input">input manager</param> /// <param name="mous">mous</param> /// <param name="cam">Camera</param> /// <param name="entities">all entities</param> public void InputUpdate(CompMouse mous, GameCam cam, List <Entity> entities) { if (InputManager.CheckButtonDown("Cast Spell", false, false) && _lastShapeClicked >= 0) { Identify(ShapeRegistry.Shapes[_lastShapeClicked]); ShapeRegistry.Cast(_lastShapeClicked); ShapeRegistry.Shapes.RemoveAt(_lastShapeClicked); _lastShapeClicked = _lastPointClicked = -1; } InputManager.CheckButtonDown("Open Magic Mode", false, false, true); _magicMode = InputManager.getToggle("Open Magic Mode"); if (_movingPnt) { if (!InputManager.CheckButtonDown("Add/Select Spell Point", false, false)) { Identify(ShapeRegistry.Shapes[_lastShapeClicked]); //if (!_heldControl) // _lastPointClicked = -1; _movingPnt = false; _moveWait = 0; } } InputManager.CheckButtonDown("Speed Creation Mode", false, true); if (InputManager.CheckButtonDown("Add/Select Spell Point", false, false)) { if (!_movingPnt) { if (_lastPointClicked >= 0) { if (ShapeRegistry.Shapes[_lastShapeClicked].Points[_lastPointClicked].intersects(mous, ShapeRegistry.PointSize, cam)) { if (_moveWait < 5) { _moveWait++; } else { _moveWait = 0; _movingPnt = true; _lastMouseLoc = mous.Location; } } } } else { ShapeRegistry.Shapes[_lastShapeClicked].Points[_lastPointClicked]._location -= _lastMouseLoc - mous.Location; ShapeRegistry.Shapes[_lastShapeClicked].Points[_lastPointClicked].MoveToLocation = ShapeRegistry.Shapes[_lastShapeClicked].Points[_lastPointClicked]._location; if (ShapeRegistry.Shapes[_lastShapeClicked].Target == null) { foreach (Entity ent in entities) { if (ShapeRegistry.Shapes[_lastShapeClicked].Points[_lastPointClicked].intersects(ent, ShapeRegistry.PointSize, cam)) { ShapeRegistry.Shapes[_lastShapeClicked].Target = ent; ShapeRegistry.Shapes[_lastShapeClicked].PointAttachment = _lastPointClicked; } } } else { if (!ShapeRegistry.Shapes[_lastShapeClicked].Points[_lastPointClicked].intersects(ShapeRegistry.Shapes[_lastShapeClicked].Target, ShapeRegistry.PointSize, cam) && ShapeRegistry.Shapes[_lastShapeClicked].PointAttachment == _lastPointClicked) { ShapeRegistry.Shapes[_lastShapeClicked].Target = null; (ShapeRegistry.Shapes[_lastShapeClicked]).FirstTarget = false; } } _lastMouseLoc = mous.Location; } } if (InputManager.CheckButtonDown("Add/Select Spell Point", true, false) && _magicMode) { _clicked = false; _curCombineShpe = -1; _curCombinePnt = -1; foreach (IShape shpe in ShapeRegistry.Shapes) { _temSh = shpe; _tempindex = ShapeRegistry.Shapes.IndexOf(shpe); ShapeRegistry.isonscreen(shpe, cam); if (ShapeRegistry.PointsOnScreen.Count > 0) { foreach (MagicPoint pnt in ShapeRegistry.PointsOnScreen) { if (pnt.intersects(mous, ShapeRegistry.PointSize, cam)) { if (_lastPointClicked >= 0) { if (_lastShapeClicked == ShapeRegistry.Shapes.IndexOf(shpe)) { bool exists = false; if (shpe.Points[_lastPointClicked].Connections.Contains(pnt.ID)) { exists = true; } if (!exists && _lastPointClicked != shpe.Points.IndexOf(pnt)) { ShapeRegistry.AddInternalConnection(_lastPointClicked, pnt.ID, shpe); Identify(shpe); if (InputManager.isBeingHeld("Speed Creation Mode")) { _heldControl = true; _lastPointClicked = pnt.ID; } else { _lastPointClicked = -1; } } else { _lastPointClicked = pnt.ID; } } else { _curCombineShpe = ShapeRegistry.Shapes.IndexOf(shpe); _curCombinePnt = pnt.ID; } } else { _lastPointClicked = pnt.ID; _lastShapeClicked = ShapeRegistry.Shapes.IndexOf(shpe); } _clicked = true; } } } } if (_tempindex >= 0) { ShapeRegistry.Shapes[_tempindex] = _temSh; } if (!_clicked) { if (_heldControl && _lastPointClicked != -1) { ShapeRegistry.Addshape(mous.Location, _rand, entities, false); ShapeRegistry.CombineShape(new Shape(true), _lastShapeClicked, ShapeRegistry.Shapes.Count - 1, _lastPointClicked, 0, entities, false); } else { ShapeRegistry.Addshape(mous.Location, _rand, entities, true); } _lastShapeClicked = ShapeRegistry.Shapes.Count - 1; _lastPointClicked = 0; Identify(ShapeRegistry.Shapes[_lastShapeClicked]); if (InputManager.isBeingHeld("Speed Creation Mode")) { _heldControl = true; _lastPointClicked = ShapeRegistry.Shapes[_lastShapeClicked].Points.Count - 1; } else { _curCombinePnt = _curCombineShpe = _lastPointClicked = -1; } } if (_lastShapeClicked != -1 && _lastPointClicked != -1 && _curCombinePnt != -1 && _curCombineShpe != -1) { int i = _curCombinePnt + ShapeRegistry.Shapes[_lastShapeClicked].Points.Count; ShapeRegistry.CombineShape(new Shape(true), ShapeRegistry.Shapes[_lastShapeClicked], ShapeRegistry.Shapes[_curCombineShpe], _lastPointClicked, _curCombinePnt, entities, true); _lastShapeClicked = ShapeRegistry.Shapes.Count - 1; if (InputManager.isBeingHeld("Speed Creation Mode")) { _heldControl = true; _lastPointClicked = i; _curCombinePnt = _curCombineShpe = -1; } else { _curCombinePnt = _curCombineShpe = _lastPointClicked = -1; } Identify(ShapeRegistry.Shapes[_lastShapeClicked]); } } if (InputManager.CheckButtonDown("Remove Spell Points/Connections", true, false) && _magicMode) { _clicked = false; foreach (IShape shpe in ShapeRegistry.Shapes) { ShapeRegistry.isonscreen(shpe, cam); if (ShapeRegistry.PointsOnScreen.Count > 0) { foreach (MagicPoint pnt in ShapeRegistry.PointsOnScreen) { if (pnt.intersects(mous, ShapeRegistry.PointSize, cam)) { _removePnt = pnt.ID; _removeShape = ShapeRegistry.Shapes.IndexOf(shpe); Identify(shpe); _clicked = true; } } } } if (_removePnt != -1) { ShapeRegistry.Shapes[_removeShape] = ShapeRegistry.RemovePoint(_removePnt, ShapeRegistry.Shapes[_removeShape]); } if (ShapeRegistry.Shapes[_removeShape].Points.Count == 0) { if (_lastShapeClicked == _removeShape) { _lastShapeClicked = -1; } _lastPointClicked = -1; ShapeRegistry.Shapes.RemoveAt(_removeShape); } if (_removePnt != -1) { if (_lastPointClicked == _removePnt && _lastShapeClicked == _removeShape) { _lastPointClicked = -1; } _movingPnt = false; _moveWait = 0; _removePnt = -1; } if (!_clicked) { int temin = -1; foreach (Shape shpe in ShapeRegistry.Shapes) { int rem = -1; int pntID = -1; bool done = false; foreach (MagicPoint pnt in shpe.Points) { foreach (int i in pnt.Connections) { if (!done) { if (IShapeMethods.intersectCon(mous, shpe.Points[pnt.ID]._location, shpe.Points[i]._location, ShapeRegistry.PointSize, cam)) { _temSh = shpe; temin = ShapeRegistry.Shapes.IndexOf(_temSh); rem = i; _clicked = true; _lastPointClicked = -1; _movingPnt = false; _moveWait = 0; pntID = pnt.ID; if (InputManager.CheckButtonDown("Spell Separation", false, false)) { _lastShapeClicked = -1; } done = true; } } } } if (InputManager.CheckButtonDown("Spell Separation", false, false) && temin > -1) { _pointsInShape.RemoveAll(RemoveAllin); _pointsInShape.Add(rem); foreach (int i in shpe.Points[rem]._connections) { _pointsInShape.Add(rem); } if (_pointsInShape.Count > 1) { CheckforSeparation(_pointsInShape, _temSh, 1, rem); } if (_pointsInShape.Count < _temSh.Points.Count) { _pntDic = new Dictionary <int, int>(); _sh = new Shape(true); foreach (int i in _pointsInShape) { _sh.Points.Add(_temSh.Points[i]); } for (int i = 0; i < _pointsInShape.Count; i++) { _pntDic.Add(_pointsInShape[i], _sh.Points.IndexOf(_temSh.Points[_pointsInShape[i]])); } for (int i = 0; i < _pointsInShape.Count; i++) { _temSh.Points.RemoveAt(_pointsInShape[i]); for (int n = i; n < _pointsInShape.Count; n++) { if (_pointsInShape[n] > _pointsInShape[i]) { _pointsInShape[n]--; } } } } } if (rem != -1) { ShapeRegistry.removeConnection(rem, pntID, _temSh); } } if (temin > -1) { ShapeRegistry.Shapes[temin] = _temSh; Identify(_temSh); if (InputManager.CheckButtonDown("Spell Separation", false, false) && _sh != null) { Identify(_sh); ShapeRegistry.Shapes.Add(_sh); } } } if (!_clicked) { _lastPointClicked = _lastShapeClicked = -1; } else { if (_removeShape != -1) { ShapeRegistry.Shapes.RemoveAt(_removeShape); } _removeShape = -1; } } if (InputManager.CheckButtonDown("Clear Spells", true, false) && _magicMode) { _clicked = false; foreach (Shape shpe in ShapeRegistry.Shapes) { ShapeRegistry.isonscreen(shpe, cam); if (ShapeRegistry.PointsOnScreen.Count > 0) { foreach (MagicPoint pnt in ShapeRegistry.PointsOnScreen) { if (pnt.intersects(mous, ShapeRegistry.PointSize, cam)) { _removeShape = ShapeRegistry.Shapes.IndexOf(shpe); _clicked = true; } } } } if (!_clicked) { foreach (Shape shpe in ShapeRegistry.Shapes) { _temSh = shpe; _tempindex = ShapeRegistry.Shapes.IndexOf(shpe); ShapeRegistry.isonscreen(shpe, cam); if (ShapeRegistry.PointsOnScreen.Count > 0) { foreach (MagicPoint pnt in shpe.Points) { foreach (int i in pnt.Connections) { if (IShapeMethods.intersectCon(mous, shpe.Points[pnt.ID]._location, shpe.Points[i]._location, ShapeRegistry.PointSize, cam)) { _conClicked = true; _clicked = true; } } } if (_conClicked) { _conClicked = false; } } } if (_tempindex >= 0) { ShapeRegistry.Shapes[_tempindex] = _temSh; } } if (!_clicked) { ShapeRegistry.Shapes = new List <IShape>(); _lastShapeClicked = _lastPointClicked = -1; } else if (_removeShape != -1) { ShapeRegistry.Shapes.RemoveAt(_removeShape); if (_removeShape == _lastShapeClicked) { _lastShapeClicked = _lastPointClicked = -1; } _removeShape = -1; _movingPnt = false; _moveWait = 0; } } _tempindex = -1; }