public Projectile(Entity entity, ComponentPrototype proto) : base(entity) { speed = DReal.Parse(proto.data["speed"]); directDamage = DReal.Parse(proto.data["directDamage"]); splashDamage = DReal.Parse(proto.data["splashDamage"]); splashRadius = DReal.Parse(proto.data["splashRadius"]); }
public Collider(Entity entity, ComponentPrototype proto) : base(entity) { height = DReal.Parse(proto.data["height"]); radius = DReal.Parse(proto.data["radius"]); fixedPosition = proto.data["fixedPosition"] == "true"; pushy = proto.data["pushy"] == "true"; }
public bool CheckBuildPlacement(int id, DVector3 position) { // Eugh. Poke around in the prototype for the collider (if any). var radius = (DReal)0; var proto = World.current.entityPrototypes[buildables[id]]; foreach (var cproto in proto.components) { if (cproto.kind == "Collider") { radius = DReal.Parse(cproto.data["radius"]); } } if (World.current.FindEntitiesWithinRadius(position, radius * 2).Any()) { return(false); } // Must be within a build radius. foreach (var ent in World.current.entities.Where(e => e.team == entity.team)) { var br = ent.GetComponent <BuildRadius>(); if (br != null && br.Contains(position, radius)) { return(true); } } return(false); }
public Wizard(Entity entity, ComponentPrototype proto) : base(entity) { towerPrototype = proto.data["tower"]; towerBuildCooldown = DReal.Parse(World.current.entityPrototypes[towerPrototype].data["buildTime"]); towerBuildCooldownRemaining = towerBuildCooldown; tower = null; }
public WizardTower(Entity entity, ComponentPrototype proto) : base(entity) { harvesterPrototype = proto.data["harvester"]; harvesterBuildCooldown = DReal.Parse(World.current.entityPrototypes[harvesterPrototype].data["buildTime"]); wizardPrototype = proto.data["wizard"]; wizardBuildCooldown = DReal.Parse(World.current.entityPrototypes[harvesterPrototype].data["buildTime"]); }
public ResourceHarvester(Entity entity, ComponentPrototype proto) : base(entity) { this.motor = entity.GetComponent <IMotor>(); resourceId = World.current.resourceNameToId[proto.data["resource"]]; capacity = DReal.Parse(proto.data["capacity"]); fillRate = DReal.Parse(proto.data["rate"]); this.fill = 0; }
public Mine(Entity entity, ComponentPrototype proto) : base(entity) { this.rate = DReal.Parse(proto.data["rate"]); var resource = World.current.resourceNameToId[proto.data["resource"]]; var team_ent = World.current.entities.First(e => e.team == entity.team && e.GetComponents <ResourcePool>().Any(p => p.resourceId == resource)); pool = team_ent.GetComponents <ResourcePool>().First(p => p.resourceId == resource); }
public AirMotor(Entity entity, ComponentPrototype proto) : base(entity) { moveSpeed = DReal.Parse(proto.data["speed"]); wobbleFrequency = DReal.Parse(proto.data["wobbleFrequency"]); wobbleAmplitude = DReal.Parse(proto.data["wobbleAmplitude"]); floatOffset = DReal.Parse(proto.data["floatOffset"]); verticalSpeed = DReal.Parse(proto.data["verticalSpeed"]); wobbleOffset = World.current.RandomValue() * DReal.PI; }
public HitscanWeapon(Entity entity, ComponentPrototype proto) : base(entity) { range = DReal.Parse(proto.data["range"]); damage = DReal.Parse(proto.data["damage"]); fireRate = DReal.Parse(proto.data["fireRate"]); sustainTime = DReal.Parse(proto.data["sustainTime"]); effect = proto.data["effect"]; refireTime = 0; sustainRemaining = 0; sustainTarget = null; }
public ProjectileWeapon(Entity entity, ComponentPrototype proto) : base(entity) { projectile = proto.data["projectile"]; range = DReal.Parse(proto.data["range"]); fireRate = DReal.Parse(proto.data["fireRate"]); randomOffset = new DVector3(DReal.Parse(proto.data["randomOffsetX"]), DReal.Parse(proto.data["randomOffsetY"]), DReal.Parse(proto.data["randomOffsetZ"])); fireTime = 0; }
public ResourcePool(Entity entity, ComponentPrototype proto) : base(entity) { this.resourceId = World.current.resourceNameToId[proto.data["resource"]]; this.fill = DReal.Parse(proto.data["initial"]); }
public BuildRadius(Entity entity, ComponentPrototype proto) : base(entity) { radius = DReal.Parse(proto.data["radius"]); }
public ResourceSet ParseResources(Dictionary <string, string> resources) { var rs = new ResourceSet(); rs.resources = resources .Select(kv => new KeyValuePair <int, DReal>(World.current.resourceNameToId.ContainsKey(kv.Key) ? World.current.resourceNameToId[kv.Key] : -1, DReal.Parse(kv.Value))) .Where(kv => kv.Key != -1) .OrderBy(kv => kv.Key) .ToArray(); return(rs); }
public override void BuildCommand(int id, DVector3 position) { if (buildInProgress) { return; } if (buildables[id] == null) { return; } position = new DVector3(position.x, World.current.map.Height(position), position.z); currentMode = World.current.entityPrototypes[buildables[id]].BuildMode(); if (currentMode == BuildMode.BUILD_IN_PLACE || currentMode == BuildMode.BUILD_IMMEDIATE) { if (!CheckBuildPlacement(id, position)) { return; } } // TODO: Check placement for BUILD_foo here. if (!HaveEnoughResources(id)) { return; } ConsumeResources(id, false); buildInProgress = true; totalTime = DReal.Parse(World.current.entityPrototypes[buildables[id]].data["buildTime"]); remainingTime = totalTime; buildingWhat = id; buildingPosition = position; switch (currentMode) { case BuildMode.SPAWN: break; case BuildMode.SPAWN_IMMEDIATE: World.current.Instantiate(buildables[buildingWhat], entity.team, entity.RandomSpawnPosition(spawnMin, spawnMax)); World.current.eventListener.Animate(entity, "Spawn"); break; case BuildMode.BUILD_THEN_PLACE: break; case BuildMode.BUILD_IN_PLACE: var proto = World.current.entityPrototypes[buildables[id]]; var ent = new Entity(entity.team, position, proto); // Only instantiate the collider and the health component, if any. foreach (var cproto in proto.components) { if (cproto.kind == "Collider") { ent.AddComponent(new Collider(ent, cproto)); } else if (cproto.kind == "Health") { ent.AddComponent(new Health(ent, cproto)); } } inPlaceConstruction = new PartialBuilding(ent); ent.AddComponent(inPlaceConstruction); break; case BuildMode.BUILD_IMMEDIATE: World.current.Instantiate(buildables[buildingWhat], entity.team, buildingPosition); break; } }
public ResourceSource(Entity entity, ComponentPrototype proto) : base(entity) { this.resourceId = World.current.resourceNameToId[proto.data["resource"]]; this.remainingCount = DReal.Parse(proto.data["initial"]); this.occupied = false; }
public GroundMotor(Entity entity, ComponentPrototype proto) : base(entity) { moveSpeed = DReal.Parse(proto.data["speed"]); }
public Health(Entity entity, ComponentPrototype proto) : base(entity) { max = DReal.Parse(proto.data["max"]); current = max; }