public bool SetRotation() { this.lastrotation = this.currotation; this.InterpolateRotation = false; if (!this.RotationChanged) { return(false); } this.RotationChanged = false; this.HasInterpolated = false; this.InterpolateRotation = true; this.rotation = this.CacheRotation; this.dCollider.Rotation = this.rotation; float num = this.Rotation.x.ToFloat(); FInt rotation = this.Rotation.y; this.currotation = Quaternion.LookRotation(new Vector3(num, 0f, rotation.ToFloat())); if (this.Children != null) { foreach (Body child in this.Children) { child.LocalStartRotation.Rotate(this.rotation.x.RawValue, this.rotation.y.RawValue, out child.CacheRotation); child.RotationChanged = true; child.LocalStartPosition.Rotate(this.rotation.x.RawValue, this.rotation.y.RawValue, out child.position); child.position.Add(ref this.position, out child.position); child.PositionChanged = true; } } return(true); }
public void Setup(InputModule input, FInt startx, FInt starty, int team, string name) { this.input = input; position.x = startx; position.y = starty; this.team = team + 1; playerName = name; transform.position = new Vector3(startx.ToFloat(), starty.ToFloat()); sword.Setup(this); }
public void Advance() { if (swingDuration > Game.TIMESTEP) { hilt.gameObject.SetActive(true); swingDuration -= Game.TIMESTEP; FInt pct = swingDuration / maxDuration; switch (state) { case SwingState.STAB: position.x = 150 * (new FInt(1L) - pct) * FInt.Cos(angle + FInt.PI / 2); position.y = new FInt(61) + 150 * (new FInt(1L) - pct) * FInt.Sin(angle + FInt.PI / 2); rotation = angle; break; case SwingState.CWISE: position.x = 150 * FInt.Cos(angle + (new FInt(2) - pct) * FInt.PI / 2); position.y = new FInt(61) + 150 * FInt.Sin(angle + (new FInt(2) - pct) * FInt.PI / 2); rotation = angle + (-pct + 1) * FInt.PI / 2; break; case SwingState.CCWISE: position.x = 150 * FInt.Cos(angle + pct * FInt.PI / 2); position.y = new FInt(61) + 150 * FInt.Sin(angle + pct * FInt.PI / 2); rotation = angle - (-pct + 1) * FInt.PI / 2; break; } transform.localPosition = new Vector3(position.x.ToFloat(), position.y.ToFloat()); transform.localEulerAngles = new Vector3(0, 0, rotation.ToFloat() * 180 / Mathf.PI); hilt.position = position; CheckCollisions(); } else { hilt.gameObject.SetActive(false); if (swingCooldown > 0L) { swingCooldown -= Game.TIMESTEP; } else { state = SwingState.NONE; } } }
public void Attach(Node attachPoint, int myPoint, GameObject sword, Player player) { this.player = player; parent = attachPoint.parent; // Attach this sword part by making the node point at myPoint // equivelant to the attach point FInt a1 = FInt.Atan(nodePoints[myPoint].dir.x, nodePoints[myPoint].dir.y); FInt a2 = FInt.Atan(attachPoint.dir.x, attachPoint.dir.y); FInt angle = a2 - a1 + new FInt(3.1415f); rotation = angle; FInt px = nodePoints[myPoint].pos.x; FInt py = nodePoints[myPoint].pos.y; FInt length = FInt.Sqrt((px * px) + (py * py)); FInt a3 = FInt.Atan(px, py); FInt transx = length * FInt.Cos(a3 + angle); FInt transy = length * FInt.Sin(a3 + angle); position = new FVector(attachPoint.pos.x - transx, attachPoint.pos.y - transy); transform.localEulerAngles = new Vector3(0, 0, rotation.ToFloat() * 180.0f / Mathf.PI); transform.localPosition = new Vector3(_position.x.ToFloat(), _position.y.ToFloat()); // TODO: Find depthInSword via recursive transformations // BREAKS: Proper sword construction }
/// <summary> /// post processing attributes to ensure ability to influence some statistics can increase other. /// In effect this produces "Final" attributes which are result of "Base" attributes plus "Changes" /// Attribute Process: /// Base - permanent attributes of the item/character, which are not recalculated often, but can be change in game /// Changes - modifiers applied to the base. Eg traits, effects, item bonuses... /// Final - AttributesProcessing function which ensures there is a way to post process special connections between tags. /// </summary> /// <param name="a"></param> /// <returns></returns> static public object AttributesProcessing(Attributes a, Character c, bool returnChangelog) { a.finalAttributes = new NetDictionary <DBReference <Tag>, FInt>(); //from, to, how much change occurred. This is so that it can be later processed //for additional information on "extra info" popups //string - ID of the skill or item which influenced change //Tag - attribute changed by the process //FInt - amount of the change List <Multitype <long, Tag, FInt, bool> > changelog = null; if (returnChangelog) { changelog = new List <Multitype <long, Tag, FInt, bool> >(); } foreach (var pair in a.baseAttributes) { a.finalAttributes[pair.Key] = pair.Value; } Dictionary <Tag, FInt> addons = new Dictionary <Tag, FInt>(); Dictionary <Tag, float> multipliers = new Dictionary <Tag, float>(); if (c != null) { //this is a character therefore trigger passive skills which influence attributes //Process skills in slots foreach (var v in c.learnedSkills) { foreach (var k in v.source.Get().skillSubskills) { if (k.trigger.triggerGroup == ETriggerGroupType.Passive) { Globals.CallFunction(k.activation.scriptName, v.GetCurrentSkillAttributes()[k], addons, multipliers, DescriptionInfoUtils.GetInfoID(v.source.Get().descriptionInfo), changelog, c); } } } //Process skills in effects on character foreach (var v in c.effects) { foreach (var k in v.source.Get().skillSubskills) { if (k.trigger.triggerGroup == ETriggerGroupType.Passive) { Globals.CallFunction(k.activation.scriptName, v.GetCurrentSkillAttributes()[k], addons, multipliers, DescriptionInfoUtils.GetInfoID(v.source.Get().descriptionInfo), changelog, c); } } } //Process skills from items foreach (SkillInstance v in c.equipmentEffects) { foreach (Subskill k in v.source.Get().skillSubskills) { if (k.trigger.triggerGroup == ETriggerGroupType.Passive) { // string itemID = null; // foreach (var i in c.equipment) // { // if (i != null && // i.Get() != null && // i.Get().skill == v) // { // itemID = i.Get().GetDescriptionInfo().GetInfoID().ToString(); // break; // } // } Globals.CallFunction(k.activation.scriptName, v.GetCurrentSkillAttributes()[k], addons, multipliers, DescriptionInfoUtils.GetInfoID(v.source.Get().descriptionInfo), changelog, c); } } } foreach (var add in addons) { if (a.finalAttributes.ContainsKey(add.Key)) { a.finalAttributes[add.Key] += add.Value; } else { a.finalAttributes[add.Key] = add.Value; } } foreach (var mul in multipliers) { if (a.finalAttributes.ContainsKey(mul.Key)) { a.finalAttributes[mul.Key] = a.finalAttributes[mul.Key] * mul.Value; } } } //main attributes to secondary conversion //NOTE: attributes which gets processing should not be parent tags for any other tag as they are //add for this reason only at late stage Tag tag = Globals.GetInstanceFromDB <Tag>(TAG.WITS); if (a.finalAttributes.ContainsKey(tag)) { FInt wits = a.finalAttributes[tag]; //use special function to calculate delay FInt delay; if (wits.ToFloat() <= 16f) { delay = 4f - (wits / 4f); } else { // - Sqrt( x/2 - 8) / 2 //delay 0 at wits 16, //delay -1 at wits 24, = sqrt(4) / 2 //delay -2 at wits 48, = sqrt(16) / 2 //delay -3 at wits 88, = sqrt(36) / 2 //delay -4 at wits 144, = sqrt(64) / 2 //delay -5 at wits 216, = sqrt(100) / 2 delay = (FInt)Mathf.Pow(wits.ToFloat() * 0.5f - 8f, 0.5f) * (-0.5f); } SimpleApplyModifier(a.finalAttributes, tag, Globals.GetInstanceFromDB <Tag>(TAG.DELAY), delay, multipliers, changelog); } else { //write down without calculation if wits are not on character attribute list SimpleApplyModifier(a.finalAttributes, tag, Globals.GetInstanceFromDB <Tag>(TAG.DELAY), new FInt(4), multipliers, changelog); } tag = Globals.GetInstanceFromDB <Tag>(TAG.STRENGTH); if (a.finalAttributes.ContainsKey(tag)) { FInt value = a.finalAttributes[tag]; SimpleApplyModifier(a.finalAttributes, tag, Globals.GetInstanceFromDB <Tag>(TAG.PERSONAL_CARRY_LIMIT), GameplayUtils.GetCarryValue(value.ToInt()), multipliers, changelog); SimpleApplyModifier(a.finalAttributes, tag, Globals.GetInstanceFromDB <Tag>(TAG.MAX_HEALTH_PHYSICAL), 1f * value, multipliers, changelog); } tag = Globals.GetInstanceFromDB <Tag>(TAG.PERCEPTION); if (a.finalAttributes.ContainsKey(tag)) { FInt value = a.finalAttributes[tag]; SimpleApplyModifier(a.finalAttributes, tag, Globals.GetInstanceFromDB <Tag>(TAG.MAX_HEALTH_PHYSICAL), 0.5f * value, multipliers, changelog); SimpleApplyModifier(a.finalAttributes, tag, Globals.GetInstanceFromDB <Tag>(TAG.GATHERING), 0.4f * value, multipliers, changelog); SimpleApplyModifier(a.finalAttributes, tag, Globals.GetInstanceFromDB <Tag>(TAG.LUCK), 0.2f * value, multipliers, changelog); } tag = Globals.GetInstanceFromDB <Tag>(TAG.INTELLIGENCE); if (a.finalAttributes.ContainsKey(tag)) { FInt value = a.finalAttributes[tag]; SimpleApplyModifier(a.finalAttributes, tag, Globals.GetInstanceFromDB <Tag>(TAG.MAX_HEALTH_MENTAL), 1f * value, multipliers, changelog); SimpleApplyModifier(a.finalAttributes, tag, Globals.GetInstanceFromDB <Tag>(TAG.RESEARCH), 0.4f * value, multipliers, changelog); SimpleApplyModifier(a.finalAttributes, tag, Globals.GetInstanceFromDB <Tag>(TAG.CRAFTING), 0.2f * value, multipliers, changelog); } tag = Globals.GetInstanceFromDB <Tag>(TAG.WISDOM); if (a.finalAttributes.ContainsKey(tag)) { FInt value = a.finalAttributes[tag]; SimpleApplyModifier(a.finalAttributes, tag, Globals.GetInstanceFromDB <Tag>(TAG.MAX_HEALTH_MENTAL), 0.5f * value, multipliers, changelog); SimpleApplyModifier(a.finalAttributes, tag, Globals.GetInstanceFromDB <Tag>(TAG.LUCK), 0.1f * value, multipliers, changelog); SimpleApplyModifier(a.finalAttributes, tag, Globals.GetInstanceFromDB <Tag>(TAG.RITUALS), 0.2f * value, multipliers, changelog); SimpleApplyModifier(a.finalAttributes, tag, Globals.GetInstanceFromDB <Tag>(TAG.CRAFTING), 0.4f * value, multipliers, changelog); SimpleApplyModifier(a.finalAttributes, tag, Globals.GetInstanceFromDB <Tag>(TAG.GATHERING), 0.2f * value, multipliers, changelog); } tag = Globals.GetInstanceFromDB <Tag>(TAG.MYSTICISM); if (a.finalAttributes.ContainsKey(tag)) { FInt value = a.finalAttributes[tag]; SimpleApplyModifier(a.finalAttributes, tag, Globals.GetInstanceFromDB <Tag>(TAG.MAX_HEALTH_SPIRIT), 1f * value, multipliers, changelog); SimpleApplyModifier(a.finalAttributes, tag, Globals.GetInstanceFromDB <Tag>(TAG.RESEARCH), 0.2f * value, multipliers, changelog); SimpleApplyModifier(a.finalAttributes, tag, Globals.GetInstanceFromDB <Tag>(TAG.RITUALS), 0.4f * value, multipliers, changelog); } tag = Globals.GetInstanceFromDB <Tag>(TAG.DESTINY); if (a.finalAttributes.ContainsKey(tag)) { FInt value = a.finalAttributes[tag]; SimpleApplyModifier(a.finalAttributes, tag, Globals.GetInstanceFromDB <Tag>(TAG.MAX_HEALTH_SPIRIT), .5f * value, multipliers, changelog); SimpleApplyModifier(a.finalAttributes, tag, Globals.GetInstanceFromDB <Tag>(TAG.GATHERING), 0.1f * value, multipliers, changelog); SimpleApplyModifier(a.finalAttributes, tag, Globals.GetInstanceFromDB <Tag>(TAG.RESEARCH), 0.1f * value, multipliers, changelog); SimpleApplyModifier(a.finalAttributes, tag, (Tag)TAG.LUCK, 0.4f * value, multipliers, changelog); SimpleApplyModifier(a.finalAttributes, tag, Globals.GetInstanceFromDB <Tag>(TAG.RITUALS), 0.1f * value, multipliers, changelog); SimpleApplyModifier(a.finalAttributes, tag, Globals.GetInstanceFromDB <Tag>(TAG.CRAFTING), 0.1f * value, multipliers, changelog); } //Apply all values to their parents so that they can be sampled easy later //we are using presorted list which ensures that we will process leafs first, therefore //no parent would be processed before its child to ensure that parent can influence //its own parents including this bonus without double processing List <Tag> tags = DBTypeUtils <Tag> .GetParentSortedType(); foreach (Tag t in tags) { if (a.finalAttributes.ContainsKey(t)) { FInt bonus = a.finalAttributes[t]; HashSet <Tag> parents = DBTypeUtils <Tag> .GetParentsOf(t); foreach (Tag parent in parents) { if (parent == null) { Debug.LogError("[ERROR]" + parent); } if (a.finalAttributes.ContainsKey(parent)) { a.finalAttributes[parent] += bonus; } else { a.finalAttributes[parent] = bonus; } } } } if (c != null) { c.MaxCarry = a.finalAttributes[(Tag)TAG.PERSONAL_CARRY_LIMIT]; } a.ClampAndScaleHP(); a.ClearDirty(); return(changelog); }