public Building(Game game, Player player, BuildingType type, Vector3 position, float scale = 1.0f, bool selectable = false, Vector3 rotation = default(Vector3)) : base(game, player, type.Model) { timer = 5; Souls = 50; produktywnosc = 600; this.player = player; this.Position = position; this.Rotation = rotation; this.Scale = scale; this.type = (BuildingType)type.Clone(); this.messages = new List<Message>(); this.meshBoundingBoxes = new List<BoundingBox>(); maxHP = this.type.maxhp; HP = maxHP; this.selectable = selectable; buildtime = this.type.buildtime; this.game = game; Matrix[] modelTransforms = new Matrix[currentModel.Model.Bones.Count]; currentModel.Model.CopyAbsoluteBoneTransformsTo(modelTransforms); foreach (ModelMesh mesh in currentModel.Model.Meshes) { List<Vector3> meshVertices = new List<Vector3>(); Matrix transformations = modelTransforms[mesh.ParentBone.Index] * GetWorldMatrix(); VertexHelper.ExtractModelMeshData(mesh, ref transformations, meshVertices); meshBoundingBoxes.Add(BoundingBox.CreateFromPoints(meshVertices)); } ModelExtra modelExtra1 = currentModel.Model.Tag as ModelExtra; BoundingSphere originalSphere2 = modelExtra1.boundingSphere; boundingBox = BoundingBox.CreateFromSphere(XNAUtils.TransformBoundingSphere(originalSphere2, GetWorldMatrix())); }
public bool Build(BuildingType building, Vector3 position) { if (Souls >= building.Souls) { BuildingList.Add(new Building(game, this, building, position, building.Scale)); Souls -= building.Souls; // Console.WriteLine(Souls); return true; } return false; }