protected override void InitCustomComponents() { _playerMovement = GetComponent <PlayerMovement>(); _castSpell = GetComponent <CastSpell>(); _dash = GetComponent <Dash>(); _stab = GetComponent <Stab>(); }
public TreeNode BuildTree() { var treeView = new TreeNode($"{_info.Id:X8}"); var numCells = new TreeNode($"NumCells: {_info.NumCells}"); treeView.Items.Add(numCells); if (_info.Objects.Count != 0) { var objects = new TreeNode("Objects:"); foreach (var stab in _info.Objects) { var stabTree = new Stab(stab).BuildTree(); var obj = new TreeNode($"{stabTree[0].Name.Replace("ID: ", "")}"); stabTree.RemoveAt(0); obj.Items.AddRange(stabTree); objects.Items.Add(obj); } treeView.Items.Add(objects); } /*if (_info.PackMask != 0) * { * var packMask = new TreeNode($"PackMask: {_info.PackMask:X8}"); * treeView.Items.Add(packMask); * }*/ if (_info.Buildings.Count != 0) { var buildings = new TreeNode($"Buildings:"); for (var i = 0; i < _info.Buildings.Count; i++) { var building = new TreeNode($"{i}"); building.Items.AddRange(new BuildInfo(_info.Buildings[i]).BuildTree()); buildings.Items.Add(building); } treeView.Items.Add(buildings); } if (_info.RestrictionTables.Count != 0) { var restrictions = new TreeNode($"Restrictions:"); foreach (var kvp in _info.RestrictionTables) { restrictions.Items.Add(new TreeNode($"{kvp.Key:X8}: {kvp.Value:X8}")); } treeView.Items.Add(restrictions); } return(treeView); }
private void OnStab(Stab stab) { var touchMap = PlayerActionsReader.Data.touchMap; foreach (var item in touchMap) { if (item.Value) { AttackPlayer(item.Key); } } }
private static void Main(string[] args) { var sternOne = new Stern(2); var sternTwo = new Stern(4); var sternThree = new Stern(9); var stabOne = new Stab(sternOne, sternTwo, 9); var stabTwo = new Stab(stabOne, sternThree, 10); stabTwo.Balance(); stabTwo.Print(); }
// Returns the Force of a stab public static String getForce(Stab s, VariableCollection col) { String force = ""; foreach (Variable va in col.var) { String name = "F(" + s.node1 + "," + s.node2 + ")"; if (va.name.Contains(name)) { force = va.value; } } return(force); }
public void ValidateBalance_Case1() { var sternOne = new Stern(2) as INode; var sternTwo = new Stern(4) as INode; var sternThree = new Stern(9) as INode; var stabOne = new Stab(sternOne, sternTwo, 9) as INode; var stabTwo = new Stab(stabOne, sternThree, 10) as INode; stabTwo.Balance(); stabTwo.Print(); Assert.IsTrue(Math.Abs(((Stab)stabOne).Position - 6) < 0.05); Assert.IsTrue(Math.Abs(((Stab)stabTwo).Position - 6) < 0.05); }
// Returns a Stab Object as result of a name input S(diameter, node1, node2) public static Stab nameToStab(String name) { Stab st = new Stab(); int index1 = name.IndexOf("("); int index2 = name.IndexOf(")"); String stab = name.Substring((index1) + 1, (index2) - 2); String[] werte = stab.Split(','); st.node1 = werte[1]; st.node2 = werte[2]; st.diameter = werte[0]; return(st); }
private void Start() { var playerPrefab = Globals.Tools.ObjectPooling.Grab(PoolType.Player); #region Camera new CameraFollow(playerPrefab, 2); #endregion #region Audio new AudioSystem(clips, this); #endregion #region Player var pistol = new WeaponFeature(PoolType.Bullet, 20, .1f, 1); var rocket = new WeaponFeature(PoolType.Rocket, 15, .3f, 5); var weapons = new IWeapon[2]; weapons[(int)WeaponType.Pistol] = new Pistol(pistol); weapons[(int)WeaponType.RocketLauncher] = new RocketLauncher(rocket); var playerBehaviours = new IBehaviour[8]; playerBehaviours[0] = new GrowndCheck(); playerBehaviours[1] = new LookAt(); playerBehaviours[2] = new Move(2, 4); playerBehaviours[3] = new Duck(); playerBehaviours[4] = new Jump(18); playerBehaviours[5] = new Shoot(weapons); playerBehaviours[6] = new Stab(); playerBehaviours[7] = new Pick(); new Player(playerPrefab, playerBehaviours, this); #endregion #region Rewards var loot = new Loot(lootsContainer); #endregion Globals.Tools.Event.Fire(EventType.OnSFX, Globals.SoundEffects.MissionStart); // SFX }
} = new List <Stab>(); // List of objects in the cell and their positions /// <summary> /// Load the EnvCell (Dungeon/Interior Block) from the client_cell.dat /// </summary> /// <param name="landblockId">The full int32/dword landblock value as reported by the @loc command (e.g. 0x12345678)</param> /// <returns></returns> public static EnvCell ReadFromDat(uint landblockId) { // Check the FileCache so we don't need to hit the FileSystem repeatedly if (DatManager.CellDat.FileCache.ContainsKey(landblockId)) { return((EnvCell)DatManager.CellDat.FileCache[landblockId]); } else { EnvCell c = new EnvCell(); if (DatManager.CellDat.AllFiles.ContainsKey(landblockId)) { DatReader datReader = DatManager.CellDat.GetReaderForFile(landblockId); c.CellId = datReader.ReadUInt32(); c.Bitfield = datReader.ReadUInt32(); datReader.Offset += 4; // Skip ahead 4 bytes, because this is the CellId. Again. Twice. byte numTextures = datReader.ReadByte(); // Note that "portal" in this context does not refer to the swirly pink/purple thing, its basically connecting cells byte numPortals = datReader.ReadByte(); // I believe this is what cells can be seen from this one. So the engine knows what else it needs to load/draw. ushort numVisibleBlocks = datReader.ReadUInt16(); // Read what textures are used in this cell for (uint i = 0; i < numTextures; i++) { c.Textures.Add(0x08000000u + datReader.ReadUInt16()); // these are stored in the dat as short vals, so we'll make them a full dword } c.EnvironmentId = (0x0D000000u + datReader.ReadUInt16()); c.CellStructure = datReader.ReadUInt16(); c.Position = new Position(); c.Position.LandblockId = new LandblockId(landblockId); c.Position.PositionX = datReader.ReadSingle(); c.Position.PositionY = datReader.ReadSingle(); c.Position.PositionZ = datReader.ReadSingle(); c.Position.RotationW = datReader.ReadSingle(); c.Position.RotationX = datReader.ReadSingle(); c.Position.RotationY = datReader.ReadSingle(); c.Position.RotationZ = datReader.ReadSingle(); for (uint i = 0; i < numPortals; i++) { CellPortal cp = new CellPortal(); cp.Flags = datReader.ReadUInt16(); cp.EnvironmentId = datReader.ReadUInt16(); cp.OtherCellId = datReader.ReadUInt16(); cp.OtherPortalId = datReader.ReadUInt16(); cp.ExactMatch = (byte)(cp.Flags & 1); cp.PortalSide = (byte)((cp.Flags >> 1) & 1); c.CellPortals.Add(cp); } for (uint i = 0; i < numVisibleBlocks; i++) { c.VisibleBlocks.Add(datReader.ReadUInt16()); } uint numObjects = datReader.ReadUInt32(); for (uint i = 0; i < numObjects; i++) { Stab s = new Stab(); s.Model = datReader.ReadUInt32(); s.Position.LandblockId = new LandblockId(landblockId); s.Position.PositionX = datReader.ReadSingle(); s.Position.PositionY = datReader.ReadSingle(); s.Position.PositionZ = datReader.ReadSingle(); s.Position.RotationW = datReader.ReadSingle(); s.Position.RotationX = datReader.ReadSingle(); s.Position.RotationY = datReader.ReadSingle(); s.Position.RotationZ = datReader.ReadSingle(); c.StabList.Add(s); } } // Store this object in the FileCache DatManager.CellDat.FileCache[landblockId] = c; return(c); } }
/// <summary> /// Constructs a new model mesh for a static land object /// </summary> public ModelMesh(Stab stab) { Init(stab.Id, stab.Frame); }
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { // Get the BackgroundWorker that raised this event. BackgroundWorker worker = sender as BackgroundWorker; //bar.limit = tmlim; //bar.backgroundWorker1.RunWorkerAsync(); //bar.StartPosition = FormStartPosition.CenterScreen; //bar.Show(); // Assign the result of the computation // to the Result property of the DoWorkEventArgs // object. This is will be available to the // RunWorkerCompleted eventhandler. try { label20.Text = "Please wait..."; progressBar1.Value = 0; DateTime now = DateTime.Now; string datum = now.ToString("dd-MM-yyy"); datum = datum.Replace("-", ""); string csv = directory + "\\" + projectName + "_csv_" + datum + ".csv"; // Parse chosen .sol File to csv File XmlRootAttribute root = new XmlRootAttribute(); root.ElementName = "CPLEXSolution"; VariableCollection col = null; XmlSerializer s = new XmlSerializer(typeof(VariableCollection), root); StreamReader reader = new StreamReader(solFilePath); col = (VariableCollection)s.Deserialize(reader); reader.Close(); // Write deserialized data in csv file. int count = col.var.Count(); using (System.IO.StreamWriter file = new System.IO.StreamWriter(csv)) { int i = 1; // counter for number of stabs foreach (Variable va in col.var) { decimal dwert = 0; if (!va.value.Contains("e")) { string temp = va.value.Replace(".", ","); dwert = Convert.ToDecimal(temp); } if ((dwert > 0.85m) && (dwert < 1.15m)) // only stabs with value near 1 written in csv file { if (va.name.Contains("S(")) { Stab stab = nameToStab(va.name); String force = getForce(stab, col); file.WriteLine(stab.node1 + ";" + stab.node2 + ";" + stab.diameter + ";" + force); i++; } } int percentComplete = (int)((float)i / (float)count * 100); worker.ReportProgress(percentComplete); //int pro = (int)((float)i / (float)count); //worker.ReportProgress(pro*100); } //file.WriteLine("Stabs: " + i); // To check if every Stab is represented } } catch (System.Exception ex) { MessageBox.Show("An error occured: " + ex.ToString(), "Info"); } }
/// <summary> /// Constructs a new model mesh for a static land object /// </summary> public ModelInstance(Stab stab) { Init(stab.Id, stab.Frame); }