public RigidBody(GameObject o) : base(o) { Model2D model = GameObject.GetComponent<Model2D>(); if (model != null) { _model = model; Box = model.BoundingBox(); } UseGravity = true; UseCollision = true; Drag = new Vector2(2f); GameObject.RigidBody = this; MaxVelocity = _maxVelocity; // default }
private void FindModel() { _model = GameObject.GetComponent<Model2D>(); }
public RigidBody(GameObject o, SimpleJSON.JSONNode n) : base(o, n) { Model2D model = GameObject.GetComponent<Model2D>(); if(model != null) { _model = model; Box = model.BoundingBox(); } UseGravity = true; UseCollision = true; }
private void SpawnIntel(Vector2 pos) { GameObject intel = new GameObject("intel"); intel.Transform.Position = pos; intel.Transform.Scale = new Vector2(0.25f); Model2D m = new Model2D(intel, "intel"); m.LoadContent(Scene.Content); intel.AddComponent(m); intel.AddComponent<Intel>(); intel.AddComponent<RigidBody>(); }
public void SpawnEnemy(Vector2 pos, int num) { GameObject enemy = new GameObject(string.Format("enemy_{0}", num)); enemy.Transform.Scale = new Vector2(0.25f); enemy.Transform.Position = pos; Model2D model = new Model2D(enemy, "Player\\hero5"); model.LoadContent(Scene.Content); model.UseAnimations = true; enemy.AddComponent(model); Enemy e = enemy.AddComponent<Enemy>(); var r = enemy.AddComponent<RigidBody>(); r.HasDrag = true; r.Drag = Vector2.Zero; }
public void SpawnHealthPack(Vector2 pos, int num) { GameObject health = new GameObject(string.Format("health_pack_{0}", num)); Model2D model = new Model2D(health, "Player\\health"); health.AddComponent(model); health.Transform.Position = pos; health.Transform.Scale = new Vector2(0.15f); health.AddComponent<RigidBody>(); var h = health.AddComponent<Health>(); h.HealthGain = 25; }
private void ControllerInput(PlayerIndex i, Buttons b, GamePadMessage m) { if (m == GamePadMessage.Pressed && b == Buttons.Start) { if (_players[i] == null) { Vector2 spawnPos = GetSpawnPosition(); GameObject go = new GameObject(string.Format("player_{0}", i)); Console.WriteLine("Spawning Player: " + go.Name); go.Transform.Position = spawnPos; go.Transform.Scale = new Vector2(0.25f); var p = go.AddComponent<Player>(); Model2D model = new Model2D(go, string.Format("Player\\hero{0}", (int)i + 1)); go.AddComponent(model); model.UseAnimations = true; var rigid = go.AddComponent<RigidBody>(); rigid.HasDrag = true; p.Index = i; _players[i] = p; if (i == PlayerIndex.One) Camera.Instance.TrackingObject = go; } } }