private GameManager() { GameManager.terrain = CameraDriver.GetAttachedTerain(); ai = new WiccanRede.AI.AICore(terrain); this.logic = new GameLogic(this, ai); Initialization(); }
/// <summary> /// Provede svazani kamery s terenem, po kterem je mozno se pohybovat /// </summary> /// <param name="terain"></param> public static void SetAttachedTerain(WiccanRede.AI.IWalkable terain) { CameraDriver.terain = terain; }
public override void Update(float time) { float frametime = time - lasttime; if (lifetime < -1500) { fireParticle.Dispose(); this.Dispose(); return; } if (lifetime < 0) { lifetime -= frametime; return; } Vector3 frametimedirection = frametime * direction; if (!collision) { WiccanRede.AI.IWalkable terrain = WiccanRede.Graphics.CameraDriver.GetAttachedTerain(); if (terrain.IsPositionOnTerainBlocked(position)) { System.Drawing.Point coords = terrain.Get2DMapPosition(position); float height = ((Terrain)terrain).GetHeightFromCollissionMap(coords.X, coords.Y); if (position.Y <= height) { collision = true; this.enabled = false; lifetime = 100; return; } } foreach (SceneManager.SceneObject obj in objects) { if (obj.name.StartsWith(this.name)) { continue; } bool col = false; if (obj.generalObject is Objects.Player) { bool sphereCollission = obj.generalObject.ComputeSphereCollission(position) || obj.generalObject.ComputeSphereCollission(position + frametimedirection * 0.0005f) || obj.generalObject.ComputeSphereCollission(position + frametimedirection * 0.00025f) || obj.generalObject.ComputeSphereCollission(position + frametimedirection * 0.000125f) || obj.generalObject.ComputeSphereCollission(position + frametimedirection * 0.0000625f) || obj.generalObject.ComputeSphereCollission(position + frametimedirection * 0.00003125f); col = sphereCollission; } else { bool boxCollission = obj.generalObject.ComputeBoxCollission(position) || obj.generalObject.ComputeBoxCollission(position + frametimedirection * 0.0005f) || obj.generalObject.ComputeBoxCollission(position + frametimedirection * 0.00025f) || obj.generalObject.ComputeBoxCollission(position + frametimedirection * 0.000125f) || obj.generalObject.ComputeBoxCollission(position + frametimedirection * 0.0000625f) || obj.generalObject.ComputeBoxCollission(position + frametimedirection * 0.00003125f); col = boxCollission; } if (col) { if (logic != null) { if (obj.name.StartsWith("Hrac")) { logic.FireballHit("Player"); } else { logic.FireballHit(obj.name, actionInfo); } } collision = true; this.enabled = false; lifetime = 100; break; } } } base.Update(time); if (lasttime == 0) { lasttime = time; return; } if (frametime > 20) { int particlesInFrame = 25; int count = (int)(frametime * 0.05); position += frametime * direction * 0.001f; for (int i = 0; i < count; i++) { fireParticle.AddParticleSystemAtOffSet(new Vector3(position.X, position.Y, position.Z), particlesInFrame, new Vector3(0, 1, 0)); } lifetime -= frametime; lasttime = time; } fireParticle.Update(time); }