public WalkingDead(RectangleF frame) : base(frame) { BackgroundColor = UIColor.Clear; ClipsToBounds = false; head = new Head(new RectangleF(0, 0, Frame.Size.Width, Frame.Size.Height * .25f)); AddSubview(head); body = new Body(new RectangleF(0, head.Frame.GetMaxY(), Frame.Size.Width, Frame.Size.Height * .375f)); AddSubview(body); leftArm = new LeftArm(new RectangleF(0, 0, Frame.Size.Width + 20, Frame.Size.Height)); AddSubview(leftArm); rightArm = new RightArm(new RectangleF(0, 0, Frame.Size.Width, Frame.Size.Height)); AddSubview(rightArm); rightLeg = new RightLeg(new RectangleF(0, 0, Frame.Size.Width, Frame.Size.Height)); AddSubview(rightLeg); leftLeg = new LeftLeg(new RectangleF(0, 0, Frame.Size.Width, Frame.Size.Height)); AddSubview(leftLeg); TurnAround(); }
public void AddLegs() { // Individual segments for the left leg BodyPart leftHip = new BodyPart("Left Hip", LateralDirection.Left); LeftLeg leftLeg = new LeftLeg(); // Here we use the LeftLeg class instead, which inherits BodyPart BodyPart leftFoot = new BodyPart("Left Foot", LateralDirection.Left); leftLeg.SubParts.Add(leftFoot); leftHip.SubParts.Add(leftLeg); //Individual segments for the right leg BodyPart rightHip = new BodyPart("Right Hip", LateralDirection.Right); BodyPart rightLeg = new BodyPart("Right Leg", LateralDirection.Right); BodyPart rightFoot = new BodyPart("Right Foot", LateralDirection.Right); rightLeg.SubParts.Add(rightFoot); rightHip.SubParts.Add(rightLeg); // Add legs to pelvis Pelvis.BodyParts.Add(leftHip); Pelvis.BodyParts.Add(rightHip); }
void Update() { //if (transform.rotation.eulerAngles.z > 90 && transform.rotation.eulerAngles.z < 270) Kill(); //if (transform.position.x < -0.2f) //{ // net.SetFitness(-999); // net.SetTimeAlive(-999); // Kill(); //} if (dontReward) { return; } if (netInitalized && manager.Countdown > 0) { if (_shouldPunish < 0) { _shouldPunish = 0; } float[] inputs = { HeadTransform.rotation.z, LeftArmTransform.rotation.z, RightArmTransform.rotation.z, LeftLegTransform.rotation.z, LeftFootTransform.rotation.z, RightLegTransform.rotation.z, RightFootTransform.rotation.z, _shouldPunish > 0f ? 100f : 0f, transform.position.x, Chest.transform.rotation.z, Chest.velocity.x, Chest.velocity.y, LeftLeg.velocity.x, LeftLeg.velocity.y, LeftLeg.angularVelocity, LeftFoot.velocity.x, LeftFoot.velocity.y, LeftFoot.angularVelocity, RightLeg.velocity.x, RightLeg.velocity.y, RightLeg.angularVelocity, RightFoot.velocity.x, RightFoot.velocity.y, RightFoot.angularVelocity, Vector2.Distance(new Vector2(transform.position.x, 0), new Vector2(WoD.Pos, 0)) }; float[] neurons = net.FeedForward(inputs); //HeadTransform.Rotate(Vector3.forward , neurons[(int)Neuron.Head]); //LeftArmTransform.Rotate(Vector3.forward , neurons[(int)Neuron.LeftArm]); //RightArmTransform.Rotate(Vector3.forward , neurons[(int)Neuron.RightArm]); //LeftLegTransform.Rotate(Vector3.forward , neurons[(int)Neuron.LeftLeg]); //LeftFootTransform.Rotate(Vector3.forward , neurons[(int)Neuron.LeftFoot]); //RightLegTransform.Rotate(Vector3.forward , neurons[(int)Neuron.RightLeg]); //RightFootTransform.Rotate(Vector3.forward , neurons[(int)Neuron.RightFoot]); //ChestTransform.Rotate(Vector3.forward , neurons[(int)Neuron.Torso]); Head.AddTorque(neurons[(int)Neuron.Head] * 5f, ForceMode2D.Force); LeftArm.AddTorque(neurons[(int)Neuron.LeftArm] * 5f, ForceMode2D.Force); RightArm.AddTorque(neurons[(int)Neuron.RightArm] * 5f, ForceMode2D.Force); LeftLeg.AddTorque(neurons[(int)Neuron.LeftLeg] * 20f, ForceMode2D.Force); LeftFoot.AddTorque(neurons[(int)Neuron.LeftFoot] * 20f, ForceMode2D.Force); RightLeg.AddTorque(neurons[(int)Neuron.RightLeg] * 20f, ForceMode2D.Force); RightFoot.AddTorque(neurons[(int)Neuron.RightFoot] * 20f, ForceMode2D.Force); Chest.AddTorque(neurons[(int)Neuron.Torso] * 5f, ForceMode2D.Force); if (_shouldPunish > 0) { if (killTimerValue > 0) { killTimerValue -= Time.deltaTime; } else { Kill(); } } else { net.SetFitness(transform.position.x * 2); killTimerValue = killTimer; } net.SetTimeAlive(timeAlive); currentScore = net.GetFitness(); lastPosition = transform.position.x; if (WoD.Pos >= transform.position.x) { Kill(); } } timeAlive += Time.deltaTime; }
public WalkingDead (RectangleF frame) :base (frame) { BackgroundColor = UIColor.Clear; ClipsToBounds = false; head = new Head (new RectangleF (0, 0, Frame.Size.Width, Frame.Size.Height * .25f)); AddSubview (head); body = new Body (new RectangleF (0, head.Frame.GetMaxY (), Frame.Size.Width, Frame.Size.Height * .375f)); AddSubview (body); leftArm = new LeftArm (new RectangleF (0, 0, Frame.Size.Width + 20, Frame.Size.Height)); AddSubview (leftArm); rightArm = new RightArm (new RectangleF (0, 0, Frame.Size.Width, Frame.Size.Height)); AddSubview (rightArm); rightLeg = new RightLeg (new RectangleF (0, 0, Frame.Size.Width, Frame.Size.Height)); AddSubview (rightLeg); leftLeg = new LeftLeg (new RectangleF (0, 0, Frame.Size.Width, Frame.Size.Height)); AddSubview (leftLeg); TurnAround (); }
private void ExportBodypart_Click(object sender, RoutedEventArgs e) { string id = InputModname.Text + "_" + InputBodypartName.Text; if (string.IsNullOrWhiteSpace(InputModname.Text)) { LabelStatus.Content = "Export failed! Please fill out the Modname."; StatusTimer(); return; } if (string.IsNullOrWhiteSpace(InputBodypartName.Text)) { LabelStatus.Content = "Export failed! Please fill out the Bodypartname."; StatusTimer(); return; } string path; string bodytype = selectedBodytype.SelectedItem.ToString(); string color = selectedColor.SelectedItem.ToString(); string race = selectedRace.SelectedItem.ToString(); if (string.IsNullOrWhiteSpace(parentWindow.modFolderPath)) { path = System.AppDomain.CurrentDomain.BaseDirectory + "Exported\\"; } else { path = parentWindow.modFolderPath + "\\"; } string bodypart = (selectedBodypart.SelectedItem as ComboBoxItem).Content as string; Int32.TryParse(InputCharisma.Text, out int charisma); Int32.TryParse(InputConstitution.Text, out int constitution); Int32.TryParse(InputDexterity.Text, out int dexterity); Int32.TryParse(InputIntelligence.Text, out int intelligence); Int32.TryParse(InputStrength.Text, out int strength); Int32.TryParse(InputWisdom.Text, out int wisdom); path += InputModname.Text + "\\Bodyparts\\" + race + "\\" + bodypart + "s\\"; Int32.TryParse(InputHealthpoints.Text, out int maxHP); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } Bodypart b = null; switch (bodypart) { case "Head": b = new Head(constitution, intelligence, wisdom, charisma, color, bodytype, race); break; case "Torso": b = new Torso(constitution, strength, dexterity, charisma, color, bodytype, race); break; case "Right Arm": b = new RightArm(constitution, strength, dexterity, charisma, color, bodytype, race); break; case "Left Arm": b = new LeftArm(constitution, strength, dexterity, charisma, color, bodytype, race); break; case "Right Leg": b = new RightLeg(constitution, strength, dexterity, charisma, color, bodytype, race); break; case "Left Leg": b = new LeftLeg(constitution, strength, dexterity, charisma, color, bodytype, race); break; } b.id = id; b.MaxHP = maxHP; b.Name = InputBodypartName.Text; parentWindow.CopyFile(InputIconPath.Text, path); b.Icon = parentWindow.TrimPath(InputIconPath.Text); parentWindow.CopyFile(InputIdleDownAnimationPath.Text, path); b.idleDownAnimation = parentWindow.TrimPath(InputIdleDownAnimationPath.Text); parentWindow.CopyFile(InputIdleUpAnimationPath.Text, path); b.idleUpAnimation = parentWindow.TrimPath(InputIdleUpAnimationPath.Text); parentWindow.CopyFile(InputIdleRightAnimationPath.Text, path); b.idleRightAnimation = parentWindow.TrimPath(InputIdleRightAnimationPath.Text); parentWindow.CopyFile(InputIdleLeftAnimationPath.Text, path); b.idleLeftAnimation = parentWindow.TrimPath(InputIdleLeftAnimationPath.Text); parentWindow.CopyFile(InputWalkDownAnimationPath.Text, path); b.walkDownAnimation = parentWindow.TrimPath(InputWalkDownAnimationPath.Text); parentWindow.CopyFile(InputWalkUpAnimationPath.Text, path); b.walkUpAnimation = parentWindow.TrimPath(InputWalkUpAnimationPath.Text); parentWindow.CopyFile(InputWalkRightAnimationPath.Text, path); b.walkRightAnimation = parentWindow.TrimPath(InputWalkRightAnimationPath.Text); parentWindow.CopyFile(InputWalkLeftAnimationPath.Text, path); b.walkLeftAnimation = parentWindow.TrimPath(InputWalkLeftAnimationPath.Text); parentWindow.CopyFile(InputAttackDownAnimationPath.Text, path); b.attackDownAnimation = parentWindow.TrimPath(InputAttackDownAnimationPath.Text); parentWindow.CopyFile(InputAttackUpAnimationPath.Text, path); b.attackUpAnimation = parentWindow.TrimPath(InputAttackUpAnimationPath.Text); parentWindow.CopyFile(InputAttackRightAnimationPath.Text, path); b.attackRightAnimation = parentWindow.TrimPath(InputAttackRightAnimationPath.Text); parentWindow.CopyFile(InputAttackLeftAnimationPath.Text, path); b.attackLeftAnimation = parentWindow.TrimPath(InputAttackLeftAnimationPath.Text); parentWindow.CopyFile(InputMagicDownAnimationPath.Text, path); b.magicDownAnimation = parentWindow.TrimPath(InputMagicDownAnimationPath.Text); parentWindow.CopyFile(InputMagicUpAnimationPath.Text, path); b.magicUpAnimation = parentWindow.TrimPath(InputMagicUpAnimationPath.Text); parentWindow.CopyFile(InputMagicRightAnimationPath.Text, path); b.magicRightAnimation = parentWindow.TrimPath(InputMagicRightAnimationPath.Text); parentWindow.CopyFile(InputMagicLeftAnimationPath.Text, path); b.magicLeftAnimation = parentWindow.TrimPath(InputMagicLeftAnimationPath.Text); switch (bodypart) { case "Head": Head h = b as Head; h.skillIDs = new string[3] { InputSkill1.Text, InputSkill2.Text, InputSkill3.Text }; XMLManager.Save(path + id, h); break; case "Torso": Torso t = b as Torso; t.skillIDs = new string[2] { InputSkill1.Text, InputSkill2.Text }; XMLManager.Save(path + id, t); break; case "Right Arm": RightArm ra = b as RightArm; ra.skillIDs = new string[2] { InputSkill1.Text, InputSkill2.Text }; XMLManager.Save(path + id, ra); break; case "Left Arm": LeftArm la = b as LeftArm; la.skillIDs = new string[2] { InputSkill1.Text, InputSkill2.Text }; XMLManager.Save(path + id, la); break; case "Right Leg": RightLeg rl = b as RightLeg; rl.skillIDs = new string[1] { InputSkill1.Text }; XMLManager.Save(path + id, rl); break; case "Left Leg": LeftLeg ll = b as LeftLeg; ll.skillIDs = new string[1] { InputSkill1.Text }; XMLManager.Save(path + id, ll); break; } LabelStatus.Content = "Export successful."; StatusTimer(); }
public void setHero_LeftLeg(LeftLeg hero_LeftLeg) { this.hero_LeftLeg = hero_LeftLeg; }
void LeftLeg_OFF() { LeftLeg.SetActive(false); }
void LeftLeg_ON() { LeftLeg.SetActive(true); }
public bool HasSymbol(string symbol) { return(LeftLeg.Any(s => s.Symbol.Equals(symbol)) || RightLeg.Any(s => s.Symbol.Equals(symbol))); }