public Enemy(Level level, SceneGraphNode node, Vector3 relativeStartPos, Bullet.Factory createBullet) { Node = node; node.AssociatedObject = this; this.level = level; this.createBullet = createBullet; player = level.LocalPlayer; bodyNode = Node.CreateChild(); bodyNode.Relative = Matrix.Scaling(2, 2, 2) * Matrix.RotationZ(-(float)Math.PI * 0.05f); var bodyEnt = level.CreateEntityNode(bodyNode.CreateChild()); bodyEnt.Mesh = TW.Assets.LoadMesh("Scattered\\Models\\EnemyRobotParts\\Body"); sightNode = bodyNode.CreateChild(); sightEnt = level.CreateEntityNode(sightNode.CreateChild()); sightEnt.Mesh = TW.Assets.LoadMesh("Scattered\\Models\\EnemyRobotParts\\Sight_red"); tailNode = bodyNode.CreateChild(); tailNode.Relative = Matrix.Translation(new Vector3(0, -0.05f, 0)); tailEnt = level.CreateEntityNode(tailNode.CreateChild()); tailEnt.Mesh = TW.Assets.LoadMesh("Scattered\\Models\\EnemyRobotParts\\Tail"); propellorAxesNode = bodyNode.CreateChild(); propellorAxesNode.Relative = Matrix.Translation(new Vector3(-0.02f, -0.05f, 0)); var axesEnt = level.CreateEntityNode(propellorAxesNode.CreateChild()); axesEnt.Mesh = TW.Assets.LoadMesh("Scattered\\Models\\EnemyRobotParts\\PropellorAxes"); propellorLeftNode = propellorAxesNode.CreateChild(); propellorLeftNode.Relative = Matrix.Translation(new Vector3(-0.02f, 0.212f, 0.585f)); propLeftEnt = level.CreateEntityNode(propellorLeftNode.CreateChild()); propLeftEnt.Mesh = TW.Assets.LoadMesh("Scattered\\Models\\EnemyRobotParts\\Propellor"); propellorRightNode = propellorAxesNode.CreateChild(); propellorRightNode.Relative = Matrix.Translation(new Vector3(-0.02f, 0.212f, -0.585f)); propRightEnt = level.CreateEntityNode(propellorRightNode.CreateChild()); propRightEnt.Mesh = TW.Assets.LoadMesh("Scattered\\Models\\EnemyRobotParts\\Propellor"); Node.Relative = Matrix.Translation(relativeStartPos + new Vector3(0, idleHeight, 0)); currentHeight = idleHeight; Vector3 s; Quaternion r; Node.Absolute.Decompose(out s, out r, out currentPos); currentRotation = new Vector3(); newPos = currentPos; newRotation = currentRotation; startLocation = currentPos + new Vector3(0, patrolHeight - idleHeight, 0); LocalBoundingBox = new Vector3(2, 2, 2).CenteredBoundingbox(); level.AddBehaviour(node, update); }
public Storage(Level level, SceneGraphNode node) { this.level = level; Node = node; node.AssociatedObject = this; var warehouseMesh = TW.Assets.LoadMesh("Scattered\\Models\\WarehouseTile"); int sizeX = 5; int sizeY = 3; var renderNode = node.CreateChild(); renderNode.Relative = Matrix.Scaling(0.3f, 0.3f, 0.3f) * Matrix.Translation(-sizeX * 0.5f, 0, -sizeY * 0.5f);//sizeX * 0.5f, 0, sizeY * 0.5f); for (int x = 0; x < sizeX; x++) { for (int y = 0; y < sizeY; y++) { var n = renderNode.CreateChild(); itemNodes.Add(level.CreateEntityNode(n.CreateChild() .Alter(a => a.Relative = Matrix.Scaling(2, 2, 2) * Matrix.Translation(0, 0.5f, 0))) .Alter(a => a.CreateInteractable(() => onInteractItem(a)))); level.CreateEntityNode(n).Alter(c => c.Mesh = warehouseMesh) .Alter(c => c.Node.Relative = Matrix.Translation(x, 0, y)) .Alter(c => c.CreateInteractable(onInteractPad)); } } //emitter.Sound = SoundFactory.Load("Scattered\\Sound\\Ploep1.wav"); //emitter.Stop(); }
public ScatteredPlayer(Level level, SceneGraphNode node) { this.level = level; this.node = node; itemNode = level.CreateEntityNode(node.CreateChild().Alter(c => c.Relative = Matrix.Translation(0, -0.5f, -3))); Health = 1; }
public Level(OptimizedWorldOctree <IRenderable> worldOctree) { this.worldOctree = worldOctree; createItemTypes(); Node = new SceneGraphNode(); Node.AssociatedObject = this; LocalPlayer = new ScatteredPlayer(this, Node.CreateChild()); }
public Bridge(Level level, SceneGraphNode node) { Node = node; node.AssociatedObject = this; var ent = level.CreateEntityNode(node.CreateChild()); ent.Mesh = TW.Assets.LoadMesh("Scattered\\Models\\BridgeConnector"); }
public JumpPad(Level level, SceneGraphNode node) { this.level = level; Node = node; node.AssociatedObject = this; var mesh = TW.Assets.LoadMesh("Scattered\\Models\\JumpPad"); var renderNode = node.CreateChild(); level.CreateEntityNode(renderNode).Alter(c => c.Mesh = mesh) .Alter(c => c.CreateInteractable(onInteract)); landingNode = node.CreateChild(); landingNode.Relative = Matrix.Translation(new Vector3(0, 2f, 5f)); level.AddBehaviour(node, update); }
public Island(Level level, SceneGraphNode node) { Level = level; Inventory = new Inventory(); Node = node; var ent = level.CreateEntityNode(node.CreateChild()); entity = ent; SpaceAllocator = new IslandSpaceAllocator(); }
public Island CreateNewIsland(Vector3 position) { var ret = new Island(this, Node.CreateChild()) { Position = position }; ret.Node.AssociatedObject = ret; //TODO: fix this dependency in a better way? islands.Add(ret); return(ret); }
public ResourceGenerator(Level level, SceneGraphNode node, ItemType type) { this.level = level; this.type = type; Node = node; node.AssociatedObject = this; level.CreateEntityNode(node.CreateChild()) .Alter(k => k.Mesh = TW.Assets.LoadMesh("Scattered\\Models\\Infuser")) .Alter(k => k.CreateInteractable(onInteract)); containsResourcesSince = TW.Graphics.TotalRunTime; }
public JumpPadLocator(Level level, SceneGraphNode node, Matrix extratransform, JumpPad parentPad, JumpPad targetPad, bool isCurrentlySelected) { this.level = level; this.parentPad = parentPad; this.targetPad = targetPad; var mesh = isCurrentlySelected ? TW.Assets.LoadMesh("Scattered\\Models\\JumpPadLocatorSelected") : TW.Assets.LoadMesh("Scattered\\Models\\JumpPadLocator"); renderNode = node.CreateChild(); renderNode.Relative = extratransform; level.CreateEntityNode(renderNode).Alter(c => c.Mesh = mesh) .Alter(c => c.CreateInteractable(onInteract)); }
public Bullet(IObjectHandle handle, SceneGraphNode node, Vector3 position, Vector3 direction, float speed, float lifetime) { Node = node; node.Absolute = Matrix.Translation(position); Position = position; this.handle = handle; this.direction = direction; this.direction.Normalize(); this.speed = speed; this.lifetime = lifetime; var ent = handle.CreateEntityNode(node.CreateChild()); ent.Mesh = TW.Assets.LoadMesh("Scattered\\Models\\Bullet"); ent.Node.Relative = Matrix.Scaling(2, 2, 2); handle.AddBehaviour(node, Update); }
public FlightEngine(Level level, SceneGraphNode node, ItemType coalType) { this.level = level; this.coalType = coalType; Node = node; node.AssociatedObject = this; var renderNode = node.CreateChild(); level.CreateEntityNode(renderNode.CreateChild()) .Alter(e => e.Node.Relative = Matrix.RotationY(-MathHelper.PiOver2) * Matrix.Translation(new Vector3(1.5f, 0, 0))) .Alter(ent => ent.Mesh = TW.Assets.LoadMesh("Scattered\\Models\\PropellorEngine")) .Alter(e => e.CreateInteractable(onInteract)); level.CreateEntityNode(renderNode.CreateChild()) .Alter(e => e.Node.Relative = Matrix.RotationY(-MathHelper.PiOver2) * Matrix.Translation(new Vector3(-1.5f, 0, 0))) .Alter(ent => ent.Mesh = TW.Assets.LoadMesh("Scattered\\Models\\PropellorEngine")) .Alter(e => e.CreateInteractable(onInteract)); level.AddBehaviour(node, update); }
public Resource(Level level, SceneGraphNode node, ItemType type) { this.level = level; this.Type = type; Node = node; node.AssociatedObject = this; var renderNode = node.CreateChild(); entityNode = level.CreateEntityNode(renderNode.CreateChild()) .Alter(k => k.Node.Relative = Matrix.Identity) .Alter(k => k.CreateInteractable(onInteract)); panelNode = level.CreateTextPanelNode(renderNode.CreateChild()); panelNode.Node.Relative = Matrix.Translation(0, 2.5f, 0); panelNode.TextRectangle.IsBillboard = true; panelNode.TextRectangle.Radius = 0.35f; Amount = 1; level.AddBehaviour(node, AttemptMerge); }