public override void ReadData(BinaryReader stream, IDictionary <object, object> userdata, int totalSize) { Name = stream.ReadSizedString(); int length = stream.ReadInt32(); Capsules.Capacity = length; for (int i = 0; i < length; i++) { Capsules.Add(new ShapeCapsule(stream)); } length = stream.ReadInt32(); Spheres.Capacity = length; for (int i = 0; i < length; i++) { Spheres.Add(new ShapeSphere(stream)); } length = stream.ReadInt32(); Manifolds.Capacity = length; for (int i = 0; i < length; i++) { Manifolds.Add(new ShapeManifold(stream)); } }
/// <summary> /// Создаем одну сферу /// </summary> private void GenerateSphere() { GameObject go = GameObject.CreatePrimitive(PrimitiveType.Sphere); go.AddComponent <BallScript>(); Spheres.Add(go); lastGenTime = GameTime; }
private IEnumerator SphereRoutine() { while (Spheres.Count < SphereLimit) { var newSphere = SphereSpawner.Spawn().GetComponent <Sphere>(); Spheres.Add(newSphere); uiTextRefresher.Refresh($"{Spheres.Count:D3}"); yield return(QuarterSecond); } foreach (var sphere in Spheres) { sphere.ReversePullForce = true; } }
void Start() { _spheres = new List <EchoSphere>(); for (int i = 0; i < SphereCount; i++) { EchoSphere es = new EchoSphere { EchoMaterial = GetComponent <Renderer>().material, EchoColor = Color.white, SphereMaxRadius = SphereMaxRadius, FadeDelay = FadeDelay, FadeRate = FadeRate, EchoSpeed = EchoSpeed, SphereIndex = i }; Spheres.Add(es); } _currentSphere = 0; }
public HistoricalFigure(List <Property> properties, World world) : base(properties, world) { Initialize(); foreach (Property property in properties) { switch (property.Name) { case "appeared": Appeared = Convert.ToInt32(property.Value); break; case "birth_year": BirthYear = Convert.ToInt32(property.Value); break; case "birth_seconds72": BirthSeconds72 = Convert.ToInt32(property.Value); break; case "death_year": DeathYear = Convert.ToInt32(property.Value); break; case "death_seconds72": DeathSeconds72 = Convert.ToInt32(property.Value); break; case "name": Name = Formatting.InitCaps(property.Value.Replace("'", "`")); break; case "race": Race = string.Intern(Formatting.FormatRace(property.Value)); break; case "caste": Caste = string.Intern(Formatting.InitCaps(property.Value.ToLower().Replace('_', ' '))); break; case "associated_type": AssociatedType = string.Intern(Formatting.InitCaps(property.Value.ToLower().Replace('_', ' '))); break; case "deity": Deity = true; property.Known = true; break; case "skeleton": Skeleton = true; property.Known = true; break; case "force": Force = true; property.Known = true; Race = "Force"; break; case "zombie": Zombie = true; property.Known = true; break; case "ghost": Ghost = true; property.Known = true; break; case "hf_link": //Will be processed after all HFs have been loaded world.AddHFtoHfLink(this, property); property.Known = true; List <string> knownSubProperties = new List <string> { "hfid", "link_strength", "link_type" }; if (property.SubProperties != null) { foreach (string subPropertyName in knownSubProperties) { Property subProperty = property.SubProperties.FirstOrDefault(property1 => property1.Name == subPropertyName); if (subProperty != null) { subProperty.Known = true; } } } break; case "entity_link": case "entity_former_position_link": case "entity_position_link": world.AddHFtoEntityLink(this, property); property.Known = true; if (property.SubProperties != null) { foreach (string subPropertyName in KnownEntitySubProperties) { Property subProperty = property.SubProperties.FirstOrDefault(property1 => property1.Name == subPropertyName); if (subProperty != null) { subProperty.Known = true; } } } break; case "entity_reputation": world.AddReputation(this, property); property.Known = true; if (property.SubProperties != null) { foreach (string subPropertyName in Reputation.KnownReputationSubProperties) { Property subProperty = property.SubProperties.FirstOrDefault(property1 => property1.Name == subPropertyName); if (subProperty != null) { subProperty.Known = true; } } } break; case "entity_squad_link": case "entity_former_squad_link": property.Known = true; if (property.SubProperties != null) { foreach (string subPropertyName in KnownEntitySquadLinkProperties) { Property subProperty = property.SubProperties.FirstOrDefault(property1 => property1.Name == subPropertyName); if (subProperty != null) { subProperty.Known = true; } } } break; case "relationship_profile_hf": case "relationship_profile_hf_visual": property.Known = true; if (property.SubProperties != null) { RelationshipProfiles.Add(new RelationshipProfileHf(property.SubProperties)); } break; case "site_link": world.AddHFtoSiteLink(this, property); property.Known = true; if (property.SubProperties != null) { foreach (string subPropertyName in KnownSiteLinkSubProperties) { Property subProperty = property.SubProperties.FirstOrDefault(property1 => property1.Name == subPropertyName); if (subProperty != null) { subProperty.Known = true; } } } break; case "hf_skill": property.Known = true; if (property.SubProperties != null) { Skills.Add(new Skill(property.SubProperties)); } break; case "active_interaction": ActiveInteractions.Add(string.Intern(property.Value)); break; case "interaction_knowledge": InteractionKnowledge.Add(string.Intern(property.Value)); break; case "animated": Animated = true; property.Known = true; break; case "animated_string": if (AnimatedType != "") { throw new Exception("Animated Type already exists."); } AnimatedType = Formatting.InitCaps(property.Value); break; case "journey_pet": JourneyPets.Add(Formatting.FormatRace(property.Value)); break; case "goal": Goal = Formatting.InitCaps(property.Value); break; case "sphere": Spheres.Add(property.Value); break; case "current_identity_id": CurrentIdentityId = Convert.ToInt32(property.Value); break; case "used_identity_id": UsedIdentityIds.Add(Convert.ToInt32(property.Value)); break; case "ent_pop_id": EntityPopulationId = Convert.ToInt32(property.Value); break; case "holds_artifact": HoldingArtifacts.Add(world.GetArtifact(Convert.ToInt32(property.Value))); break; case "adventurer": Adventurer = true; property.Known = true; break; case "breed_id": BreedId = property.Value; if (!string.IsNullOrWhiteSpace(BreedId)) { if (world.Breeds.ContainsKey(BreedId)) { world.Breeds[BreedId].Add(this); } else { world.Breeds.Add(BreedId, new List <HistoricalFigure> { this }); } } break; case "sex": property.Known = true; break; } } if (string.IsNullOrWhiteSpace(Name)) { Name = !string.IsNullOrWhiteSpace(AnimatedType) ? Formatting.InitCaps(AnimatedType) : "(Unnamed)"; } if (Adventurer) { world.AddPlayerRelatedDwarfObjects(this); } }
public HistoricalFigure(List <Property> properties, World world) : base(properties, world) { Initialize(); List <string> knownEntitySubProperties = new List <string>() { "entity_id", "link_strength", "link_type", "position_profile_id", "start_year", "end_year" }; List <string> knownReputationSubProperties = new List <string>() { "entity_id", "unsolved_murders", "first_ageless_year", "first_ageless_season_count", "rep_enemy_fighter" }; List <string> knownSiteLinkSubProperties = new List <string>() { "link_type", "site_id", "sub_id", "entity_id" }; List <string> knownEntitySquadLinkProperties = new List <string>() { "squad_id", "squad_position", "entity_id", "start_year", "end_year" }; List <string> knownRelationshipProfileProperties = new List <string>() { "hf_id", "meet_count", "last_meet_year", "last_meet_seconds72", "rep_friendly", "rep_buddy", "rep_grudge" }; foreach (Property property in properties) { switch (property.Name) { case "appeared": Appeared = Convert.ToInt32(property.Value); break; case "birth_year": BirthYear = Convert.ToInt32(property.Value); break; case "birth_seconds72": BirthSeconds72 = Convert.ToInt32(property.Value); break; case "death_year": DeathYear = Convert.ToInt32(property.Value); break; case "death_seconds72": DeathSeconds72 = Convert.ToInt32(property.Value); break; case "name": Name = String.Intern(Formatting.InitCaps(property.Value)); break; case "race": Race = String.Intern(Formatting.FormatRace(property.Value)); break; case "caste": Caste = Formatting.InitCaps(property.Value.ToLower().Replace('_', ' ')); break; case "associated_type": AssociatedType = Formatting.InitCaps(property.Value.ToLower().Replace('_', ' ')); break; case "deity": Deity = true; property.Known = true; break; case "skeleton": Skeleton = true; property.Known = true; break; case "force": Force = true; property.Known = true; break; case "zombie": Zombie = true; property.Known = true; break; case "ghost": Ghost = true; property.Known = true; break; case "hf_link": //Will be processed after all HFs have been loaded world.AddHFtoHFLink(this, property); property.Known = true; List <string> knownSubProperties = new List <string>() { "hfid", "link_strength", "link_type" }; foreach (string subPropertyName in knownSubProperties) { Property subProperty = property.SubProperties.FirstOrDefault(property1 => property1.Name == subPropertyName); if (subProperty != null) { subProperty.Known = true; } } break; case "entity_link": case "entity_former_position_link": case "entity_position_link": world.AddHFtoEntityLink(this, property); foreach (string subPropertyName in knownEntitySubProperties) { Property subProperty = property.SubProperties.FirstOrDefault(property1 => property1.Name == subPropertyName); if (subProperty != null) { subProperty.Known = true; } } break; case "entity_reputation": world.AddReputation(this, property); foreach (string subPropertyName in knownReputationSubProperties) { Property subProperty = property.SubProperties.FirstOrDefault(property1 => property1.Name == subPropertyName); if (subProperty != null) { subProperty.Known = true; } } break; case "entity_squad_link": case "entity_former_squad_link": property.Known = true; foreach (string subPropertyName in knownEntitySquadLinkProperties) { Property subProperty = property.SubProperties.FirstOrDefault(property1 => property1.Name == subPropertyName); if (subProperty != null) { subProperty.Known = true; } } break; case "relationship_profile_hf": property.Known = true; foreach (string subPropertyName in knownRelationshipProfileProperties) { Property subProperty = property.SubProperties.FirstOrDefault(property1 => property1.Name == subPropertyName); if (subProperty != null) { subProperty.Known = true; } } break; case "site_link": world.AddHFtoSiteLink(this, property); foreach (string subPropertyName in knownSiteLinkSubProperties) { Property subProperty = property.SubProperties.FirstOrDefault(property1 => property1.Name == subPropertyName); if (subProperty != null) { subProperty.Known = true; } } break; case "hf_skill": Skills.Add(new Skill(property.SubProperties)); break; case "active_interaction": ActiveInteractions.Add(property.Value); break; case "interaction_knowledge": InteractionKnowledge.Add(property.Value); break; case "animated": Animated = true; property.Known = true; break; case "animated_string": if (AnimatedType != "") { throw new Exception("Animated Type already exists."); } AnimatedType = Formatting.InitCaps(property.Value); break; case "journey_pet": JourneyPets.Add(Formatting.FormatRace(property.Value)); break; case "goal": Goal = Formatting.InitCaps(property.Value); break; case "sphere": Spheres.Add(property.Value); break; case "current_identity_id": world.AddHFCurrentIdentity(this, Convert.ToInt32(property.Value)); break; case "used_identity_id": world.AddHFUsedIdentity(this, Convert.ToInt32(property.Value)); break; case "ent_pop_id": EntityPopulation = world.GetEntityPopulation(Convert.ToInt32(property.Value)); break; case "holds_artifact": HoldingArtifacts.Add(world.GetArtifact(Convert.ToInt32(property.Value))); break; case "adventurer": Adventurer = true; property.Known = true; break; } } if (Name == "") { Name = "(Unnamed)"; } }
public void ReadFile(string path) { var transformStack = new Stack <Matrix4x4>(); transformStack.Push(Matrix4x4.Identity); var contents = File.ReadLines(path); var vertCount = 0; foreach (var line in contents) { string[] splitLine; ObjectProperties objProps; Vector4 lightPos; Vector3 lightCol; if (line.StartsWith("#") || line == string.Empty) { continue; } else { splitLine = line.Split(new [] { ' ' }, StringSplitOptions.RemoveEmptyEntries); } var cmd = splitLine[0]; switch (cmd) { case "size": ImageWidth = int.Parse(splitLine[1]); ImageHeight = int.Parse(splitLine[2]); SetAspectRatio(); break; case "maxdepth": RecursionMaxDepth = int.Parse(splitLine[1]); break; case "maxverts": Vertices = new Vector3[int.Parse(splitLine[1])]; break; case "vertex": GetFloatCmdValues(splitLine); Vertices[vertCount++] = Get3dVectorFromFirstValues(); break; case "tri": GetFloatCmdValues(splitLine); var vert1 = Vertices[(int)CmdValues[0]]; var vert2 = Vertices[(int)CmdValues[1]]; var vert3 = Vertices[(int)CmdValues[2]]; objProps = CreateObjectProperties(); Triangles.Add(new Triangle(vert1, vert2, vert3, objProps, transformStack.Peek())); break; case "sphere": GetFloatCmdValues(splitLine); objProps = CreateObjectProperties(); var spherePos = new Vector3(CmdValues[0], CmdValues[1], CmdValues[2]); Spheres.Add(new Sphere(spherePos, CmdValues[3], objProps, transformStack.Peek())); break; case "output": OutputFilename = splitLine[1]; break; case "camera": GetFloatCmdValues(splitLine); EyeInit = new Vector3(CmdValues[0], CmdValues[1], CmdValues[2]); LookAtPoint = new Vector3(CmdValues[3], CmdValues[4], CmdValues[5]); UpInit = new Vector3(CmdValues[6], CmdValues[7], CmdValues[8]); FovYRad = Transform.ToRadians(CmdValues[9]); SetFovX(); ModelView = SetLookAtMatrix(); break; case "attenuation": GetFloatCmdValues(splitLine); Attenuation = new[] { CmdValues[0], CmdValues[1], CmdValues[2] }; break; case "ambient": GetFloatCmdValues(splitLine); Ambient = Get3dVectorFromFirstValues(); break; case "diffuse": GetFloatCmdValues(splitLine); Diffuse = Get3dVectorFromFirstValues(); break; case "specular": GetFloatCmdValues(splitLine); Specular = Get3dVectorFromFirstValues(); break; case "emission": GetFloatCmdValues(splitLine); Emission = Get3dVectorFromFirstValues(); break; case "shininess": Shininess = float.Parse(splitLine[1]); break; case "directional": GetFloatCmdValues(splitLine); lightPos = new Vector4(CmdValues[0], CmdValues[1], CmdValues[2], 0); lightCol = new Vector3(CmdValues[3], CmdValues[4], CmdValues[5]); Lights.Add(new Light(lightPos, lightCol, new float[] { 1, 0, 0 })); break; case "point": GetFloatCmdValues(splitLine); lightPos = new Vector4(CmdValues[0], CmdValues[1], CmdValues[2], 1); lightCol = new Vector3(CmdValues[3], CmdValues[4], CmdValues[5]); Lights.Add(new Light(lightPos, lightCol, Attenuation)); break; case "translate": GetFloatCmdValues(splitLine); var translateMat = GetTranslationMatrix(Get3dVectorFromFirstValues()); RightMultiplyTopStack(translateMat, transformStack); break; case "rotate": GetFloatCmdValues(splitLine); var angle = CmdValues[3]; var rotMat = GetRotationMatrix(Get3dVectorFromFirstValues(), angle); RightMultiplyTopStack(rotMat, transformStack); break; case "scale": GetFloatCmdValues(splitLine); var scaleMat = GetScaleMatrix(Get3dVectorFromFirstValues()); RightMultiplyTopStack(scaleMat, transformStack); break; case "pushTransform": transformStack.Push(transformStack.Peek()); break; case "popTransform": transformStack.Pop(); break; default: if (cmd == "maxvertnorms" || cmd == "vertexnormal" || cmd == "trinormal") { break; } throw new InvalidEnumArgumentException($"There is no such command as {cmd}"); } } }
public void StoreSphere(Sphere sphere) { Spheres.Add(sphere); uiTextRefresher.Refresh($"{Spheres.Count:D3}"); }
public void AddBall(Sphere sphere) { Spheres.Add(sphere); }
public void Add(Sphere sphere) => Spheres.Add(sphere);