public static modifier getModifierFromString(string inputStr) { modifier result = modifier.Default; if (string.Compare(inputStr, "Public", true) == 0) { result = modifier.Public; } if (string.Compare(inputStr, "Private", true) == 0) { result = modifier.Private; } if (string.Compare(inputStr, "Protected", true) == 0) { result = modifier.Public; } if (string.Compare(inputStr, "Static", true) == 0) { result = modifier.Static; } if (string.Compare(inputStr, "Final", true) == 0) { result = modifier.Final; } if (string.Compare(inputStr, "Default", true) == 0) { result = modifier.Default; } return(result); }
// get a random modifiers and apply them. void Start() { modifier prefix = ModifierHandler.GetRandomPrefix(); modifier suffix = ModifierHandler.GetRandomSuffix(); // handle prefix if (prefix != null) { prefixName = prefix.modName; foreach (KeyValuePair <string, float> pair in prefix.attributeToAmount) { checkModifiers(pair); } } // handle suffix if (suffix != null) { suffixName = suffix.modName; foreach (KeyValuePair <string, float> pair in suffix.attributeToAmount) { checkModifiers(pair); } } fullName = prefixName + " " + name + " " + suffixName; this.transform.localScale = new Vector3(size, size, transform.localScale.z); }
void Update() { //Rotate the point if (rotationSpeed != 0) { transform.Rotate(Vector3.forward * Time.deltaTime * rotationSpeed); } //Check if the mode is changed if (prevMode != mode) { SetMode(); } prevMode = mode; //If the mode is target player, rotate toward the player if (mode == modifier.player) { number = 1; Vector3 vectorToTarget = player.position - transform.position; float angleToTarget = Mathf.Atan2(vectorToTarget.y, vectorToTarget.x) * Mathf.Rad2Deg; Quaternion q = Quaternion.AngleAxis(angleToTarget, Vector3.forward); transform.rotation = Quaternion.Slerp(transform.rotation, q, 1); } }
/// <summary> /// Get value of attributes modified by buffs /// </summary> public void copyBuffsFrom(Unit unit) { foreach (modifier m in unit.buffs) { modifier newM = m.clone(); newM.parent = this; this.buffs.Add(newM); } }
public CompilationUnit(string n, type t, modifier m, long l, Package containingPackage) { name = n; type = t; modif = m; loc = l; this.containingPackage = containingPackage; isService = false; isServiceComponent = false; goRepresentation = null; }
void Awake() { // damage types: // 0. normal // 1. lightning // 2. ice // 3. fire // prefixes modifier pm1 = new modifier("Large", new string[] { "size", "movSpeed", "damage", "fireRate", "shotSize" }, new float[] { 1.2f, -2f, 5f, 0.5f, 3f }, 1); prefixes.Add(pm1); modifier pm2 = new modifier("Quick", new string[] { "size", "movSpeed", "fireRate" }, new float[] { -0.25f, 10f, -0.15f }, 2); prefixes.Add(pm2); modifier pm3 = new modifier("Lightning", new string[] { "damageType", "lightningRes" }, new float[] { 1, 50 }, 2); prefixes.Add(pm3); modifier pm4 = new modifier("Fiery", new string[] { "damageType", "fireRes" }, new float[] { 3, 50 }, 2); prefixes.Add(pm4); modifier pm5 = new modifier("Icy", new string[] { "damageType", "iceRes" }, new float[] { 2, 50 }, 2); prefixes.Add(pm5); modifier pm6 = new modifier("Armored", new string[] { "armor" }, new float[] { 50 }, 2); prefixes.Add(pm6); modifier pm7 = new modifier("Resistant", new string[] { "armor", "iceRes", "fireRes", "lightningRes" }, new float[] { 10, 10, 10, 10 }, 2); prefixes.Add(pm7); // suffixes modifier sm1 = new modifier("Of Stone", new string[] { "movSpeed", "damage" }, new float[] { -2f, 10f }, 1); suffixes.Add(sm1); modifier sm2 = new modifier("Of Swiftness", new string[] { "movSpeed", "movControl" }, new float[] { 5f, -0.05f }, 1); suffixes.Add(sm2); }
void IHasChildNode.InitChildNode(COLLADA Doc,XmlNode Child) { switch(Child.Name) { case "annotate": if(Annotates == null) Annotates = new List<annotate>(); Annotates.Add(Doc.Load<annotate>(this,Child)); break; case "semantic": Semantic = Child.Value; break; case "modifier": Modifier = (modifier)Enum.Parse(typeof(modifier),Child.Value); break; case "float": Value = float.Parse(Child.Value); break; case "float2": case "float3": case "float4": char[] Splitter = {' ','\n'}; string[] V = Child.Value.Split(Splitter,StringSplitOptions.RemoveEmptyEntries); Value = new float[V.Length]; int i = 0; while(i < V.Length) { (Value as float[])[i] = float.Parse(V[i]); i++; } break; case "sampler2D": break; } }
private static modifier getModifiers(string line){ //line は identifier まで含めた形で受け取る。'private void int myFunction'など string[] line2=line.Split(new char[]{' ',' ','\t'}); int i=line2.Length; modifier r=new modifier(); if(i>0)for(int j=0;j<i;j++){ switch(line2[i].Trim()){ case "public":r.AccessMod=accessMod.Public;break; case "private":r.AccessMod=accessMod.Private;break; case "protected":r.AccessMod=accessMod.Protected;break; case "internal":r.AccessMod=accessMod.Internal;break; case "sealed":r.InheritMod=inheritMod.Sealed;break; case "abstract":r.InheritMod=inheritMod.Abstract;break; case "virtual":r.InheritMod=inheritMod.Virtual;break; case "override":r.InheritMod=inheritMod.Override;break; case "extern":r.Extern=true;break; case "readonly":r.Readonly=true;break; } } return r; }
private bool Modify(int modify, modifier modifier) { return((modify & (int)modifier) == (int)modifier); }
private bool Modify(modifier modifier) { return((modify & modifier) == modifier); }
private void ConstructProject() { #region OsgiProject status = Status.Working; Debug.Log("Starting OSGi-Project construction!"); JSONObject tmp = jsonObj.GetField("name"); Assert.IsNotNull(tmp, "Projectname could not be found!"); currentProject = new OsgiProject(tmp.str); #endregion #region Bundle,Fragments,Compilation Units tmp = jsonObj.GetField("bundles"); Assert.IsNotNull(tmp, "Project does not contain any Bundles!"); List <JSONObject> jsonBundleList = tmp.list; List <JSONObject> jsonPackageList = jsonObj.GetField("packages").list; long maxLOC = 0; foreach (JSONObject jsonBundle in jsonBundleList) { string name = jsonBundle.GetField("name").str; string symbName = jsonBundle.GetField("symbolicName").str; Bundle currentBundle = new Bundle(name, symbName, currentProject); //Create Fragments tmp = jsonBundle.GetField("packageFragments"); if (tmp != null) { List <JSONObject> fragList = tmp.list; foreach (JSONObject frag in fragList) { JSONObject jsonPkg = frag.GetField("package"); int pkgIdx = resolvePackageReferenceIdx(jsonPkg); string fragName = jsonPackageList[pkgIdx].GetField("qualifiedName").str; Package currentFragment = new Package(currentBundle, fragName); //Create Compilation Units if (frag.GetField("compilationUnits") != null) { List <JSONObject> jsonCompUnits = frag.GetField("compilationUnits").list; foreach (JSONObject jsonCU in jsonCompUnits) { JSONObject tlt = jsonCU.GetField("topLevelType"); string tempStr = tlt.GetField("eClass").str; tempStr = tempStr.Replace(redundantString_A, ""); type type = JavaParser.getTypeFromString(tempStr); tempStr = tlt.GetField("visibility").str; tempStr = tempStr.Replace(redundantString_A, ""); modifier mod = JavaParser.getModifierFromString(tempStr); long loc = jsonCU.GetField("LOC").i; if (loc > maxLOC) { maxLOC = loc; } CompilationUnit compUnit = new CompilationUnit(tlt.GetField("name").str, type, mod, loc, currentFragment); //TODO: Add support for additional information about a compilation unit(Methods, references to others) currentFragment.addCompilationUnit(compUnit); } } currentBundle.addPackage(currentFragment); } } currentProject.addBundle(currentBundle); } GlobalVar.maximumLOCinProject = maxLOC; #endregion #region Services List <Bundle> bundles = currentProject.getBundles(); tmp = jsonObj.GetField("services"); if (tmp != null) { List <JSONObject> serviceJsonList = tmp.list; foreach (JSONObject jsonService in serviceJsonList) { string serviceName = jsonService.GetField("interfaceName").str; tmp = jsonService.GetField("interface"); CompilationUnit serviceCU = null; if (tmp != null) { Vector3 cuIdx = resolveCompilationUnitRef(tmp); serviceCU = bundles[(int)cuIdx.x].getPackages()[(int)cuIdx.y].getCompilationUnits()[(int)cuIdx.z]; serviceCU.setServiceDeclaration(true); } Service service = new Service(serviceName, serviceCU); currentProject.addService(service); } } #endregion #region Resolve import/export + construct ServiceComponents + build dependency graph int i = 0; BidirectionalGraph <GraphVertex, GraphEdge> dependencyGraph = currentProject.getDependencyGraph(); foreach (JSONObject jsonBundle in jsonBundleList) { //Resolve Exports for Bundle tmp = jsonBundle.GetField("exports"); if (tmp != null) { List <Vector2> exportList = resolvePckgFragmentRefList(tmp.list); foreach (Vector2 indexVec in exportList) { Package resolvedFragment = bundles[(int)indexVec.x].getPackages()[(int)indexVec.y]; resolvedFragment.setExport(true); bundles[i].addExportedPackage(resolvedFragment); } } //Resolve Imports for Bundle tmp = jsonBundle.GetField("imports"); if (tmp != null) { List <Vector2> importList = resolvePckgFragmentRefList(tmp.list); foreach (Vector2 indexVec in importList) { Package resolvedFragment = bundles[(int)indexVec.x].getPackages()[(int)indexVec.y]; // Ignore self Import redundancy if (string.Compare(bundles[i].getName(), resolvedFragment.getBundle().getName()) != 0) { bundles[i].addImportedPackage(resolvedFragment); //Package dependency //Check if Vertices already in Graph List <GraphVertex> allVertices = dependencyGraph.Vertices.ToList(); GraphVertex vert1 = allVertices.Find(v => (string.Equals(v.getName(), bundles[i].getName()))); GraphVertex vert2 = allVertices.Find(v => (string.Equals(v.getName(), bundles[(int)indexVec.x].getName()))); if (vert1 == null) { vert1 = new GraphVertex(bundles[i].getName()); } if (vert2 == null) { vert2 = new GraphVertex(bundles[(int)indexVec.x].getName()); } dependencyGraph.AddVertex(vert1); dependencyGraph.AddVertex(vert2); GraphEdge edge; bool edgePresent = dependencyGraph.TryGetEdge(vert1, vert2, out edge); if (edgePresent && dependencyGraph.AllowParallelEdges) { edge.incrementWeight(1f); } else { edge = new GraphEdge(vert1, vert2); dependencyGraph.AddEdge(edge); } GraphEdge opposingEdge; float bidirectionalEdgeWeight = edge.getWeight(); bool oppEdgePresent = dependencyGraph.TryGetEdge(vert2, vert1, out opposingEdge); if (oppEdgePresent) { bidirectionalEdgeWeight += opposingEdge.getWeight(); } if (bidirectionalEdgeWeight > currentProject.getMaxImportCount()) { currentProject.setMaxImportCount((int)bidirectionalEdgeWeight); } } else { Debug.Log("Spotted import redundancy in: " + bundles[i].getName()); } } } //Construct and resolve ServiceComponents List <Service> serviceList = currentProject.getServices(); tmp = jsonBundle.GetField("components"); if (tmp != null) { foreach (JSONObject jsonComponent in tmp.list) { string scName = jsonComponent.GetField("name").str; Vector3 implIdx = resolveCompilationUnitRef(jsonComponent.GetField("implementation")); CompilationUnit resolvedCu = bundles[(int)implIdx.x].getPackages()[(int)implIdx.y].getCompilationUnits()[(int)implIdx.z]; resolvedCu.setServiceComponentImpl(true); ServiceComponent sc = new ServiceComponent(scName, resolvedCu); tmp = jsonComponent.GetField("providedServices"); if (tmp != null) { List <int> serviceRefs = resolveServiceReferenceIdxList(tmp); foreach (int s in serviceRefs) { sc.addProvidedService(serviceList[s]); serviceList[s].addImplementingComponent(sc); } } tmp = jsonComponent.GetField("referencedServices"); if (tmp != null) { List <int> serviceRefs = resolveServiceReferenceIdxList(tmp); foreach (int s in serviceRefs) { sc.addReferencedService(serviceList[s]); serviceList[s].addReferencingComponent(sc); } } bundles[i].addServiceComponent(sc); } } i++; } #endregion Debug.Log("Max Import-count: " + currentProject.getMaxImportCount()); status = Status.Finished; Debug.Log("Finished OSGi-Project construction!"); cb(); }
private void pushMod(modifier mod) { click.Play(); value.modifiers.Add(mod); updateDisplay(); }
public void PushModifier(modifier m) { modifiers.Add(m); }