public override void Execute(UnitManager source, UnitManager target, Vector3 position) { if (buff.Source == null) { buff.Source = source; } target.AddBuff (buff); }
// Use this for initialization void Start() { lineRenderer = gameObject.GetComponent<LineRenderer>(); movePlane = transform.parent.GetComponent<MovePlaneOverlay>(); unitManager = GameObject.FindGameObjectWithTag("PlayerUnitManager").GetComponent<UnitManager>(); }
// Use this for initialization protected void Start () { singleton = this; selectionBox = new Rect(0,0,0,0); drawSelection = false; um = GameObject.FindObjectOfType<UnitManager>(); StartCoroutine(computeState()); }
void Start() { unitManager = GameObject.FindGameObjectWithTag("PlayerUnitManager").GetComponent<UnitManager>(); attackMoveIndicator = GameObject.FindGameObjectWithTag("PlayerUnitManager").GetComponent<AttackMoveIndicatorScript>(); mainCamera = GameObject.FindGameObjectWithTag("MainCamera"); pauseMenu = mainCamera.GetComponent<PauseMenuGUI>(); }
// Use this for initialization void Start() { curHealth = 50.0f; maxHealth = 50.0f; curInfect = 100.0f; unitManager = GameObject.FindGameObjectWithTag("PlayerUnitManager").GetComponent<UnitManager>(); }
public FrmUnit() { InitializeComponent(); // unitManager = new UnitManager(); }
public override void Execute(UnitManager source, UnitManager target, Vector3 position) { /* Execute all effects on every unitmanager found in the area * the center of the arc is determined by the staight line from the target to the position * If target is null the search will be centered at position with the arc centered * at the straight line from source to position. * If target is not null then the search will be centered at target with the arc * center facing position. */ //Get the center of the area Vector3 center; Vector3 arcCenter; if (target == null) { center = position; arcCenter = Quaternion.AngleAxis (arcOffset, Vector3.up) * (position - source.transform.position).normalized; } else { center = target.transform.position; arcCenter = Quaternion.AngleAxis (arcOffset, Vector3.up) * (position - target.transform.position).normalized; } int targetlayer = source.tag == "Player" ? RuntimeUtilities.ENEMY_LAYER : RuntimeUtilities.PLAYER_LAYER; Collider[] targets = Physics.OverlapSphere (center, radius, targetlayer); foreach (Collider hit in targets) { UnitManager hitTarget = hit.GetComponent<UnitManager> (); if (hitTarget != null) { Vector3 hitPosition = hit.transform.position - center; float angle = Vector3.Angle (arcCenter, hitPosition); if (Mathf.Abs (angle) <= arc / 2) { foreach (SerializableEffect effect in effects) { effect.Execute (source, hitTarget, center); } } } } }
//public AudioSource audioSelSoldier; //public AudioClip clipSelSoldier; void Start() { GameObject unitManagerObject = GameObject.FindGameObjectWithTag("PlayerUnitManager"); unitManager = unitManagerObject.GetComponent<UnitManager>(); //audioSelSoldier = (AudioSource) gameObject.AddComponent<AudioSource>(); //audioSelSoldier.clip = clipSelSoldier; }
// Use this for initialization void Start() { unitManager = GameObject.FindGameObjectWithTag("PlayerUnitManager").GetComponent<UnitManager>(); Cursor.SetCursor(defaultCursor, Vector2.zero, CursorMode.Auto); pressedA = qDown = wDown = eDown = rDown = false; }
public static UnitManager getInatance() { if ( _instance == null ) { _instance = new UnitManager(); } return _instance; }
// Use this for initialization void Start() { //get unit manager for selection and orders unitManager = GameObject.FindGameObjectWithTag("PlayerUnitManager").GetComponent<UnitManager> (); drawLine = transform.FindChild("drawLine"); drawCircle = transform.FindChild("drawCircle"); drawGrid = transform.FindChild("drawGrid"); }
public static UnitManager getInstance() { if (instance == null) { instance = new UnitManager(); } return instance; }
// Use this for initialization void Start() { if(unitObject == null) { unitObject = gameObject; } unitManager = GameObject.FindGameObjectWithTag("PlayerUnitManager").GetComponent<UnitManager>(); originalColor = renderer.material.color; StartCoroutine("Flash"); }
// Use this for initialization private void Start() { if (unitManager == null) { unitManager = GetComponent<UnitManager>(); } if (buildManager == null) { buildManager = GetComponent<BuildManager>(); } }
private static bool IsInstance () { if (instance == null) { instance = FindObjectOfType (typeof (UnitManager)) as UnitManager; if (instance == null) { Debug.LogError ("Can't seem to find any Gameobject that has UnitManager class"); return false; } } return true; }
Buff(UnitManager source, float totalDuration, UnitStats flatStats, UnitStats percentStats, UnitFlags flags, List<SerializableEffect> periodicEffects, float period, string animationBool) { this.source = source; this.totalDuration = totalDuration; this.duration = 0; this.flatStats = flatStats; this.percentStats = percentStats; this.flags = flags; this.periodicEffects = new List<SerializableEffect> (periodicEffects); this.period = period; this.animationBool = animationBool; }
public FrmSearchProduct(FrmDanhMucSanPham frmParent) { InitializeComponent(); productManager = new ProductManager(); productNameManager = new ProductNameManager(); categoryManager = new CategoryManager(); unitManager = new UnitManager(); countryManager = new CountryManager(); manufacturerManager = new ManufacturerManager(); productStatusManager = new ProductStatusManager(); this.frmParent = frmParent; }
/// <summary> /// Execute the Abilities effect. /// </summary> /// <param name="name">The ability name.</param> public UnitFlags Execute(UnitManager source, Vector3 mousePos) { if ((source.Flags & disableFlags) == 0) { cooldown = cooldownTime / source.Stats.cooldownRate; targetPos = mousePos; abilityFlags = new UnitFlags(windup.Start (source, mousePos, ref current)); if (current.endOnCollision) { source.AddCollisionCallback (NextPhase); } return abilityFlags; } else { return null; } }
// Use this for initialization void Start() { //get unit manager for selection and orders unitManger = GameObject.FindGameObjectWithTag("PlayerUnitManager").GetComponent<UnitManager> (); //set focus point at the game orgin (later will be player start position) transform.position = new Vector3 (0, 0, 0); //if we dont specifically setup a camera for this script it assigns it to the main camera if (detectionCamera != null) { _camera = detectionCamera; } else { _camera = Camera.main; } }
public FrmDanhMucSanPham() { InitializeComponent(); //Create Manager which will use in form productManager = new ProductManager(); productNameManager = new ProductNameManager(); productStatusManager = new ProductStatusManager(); unitManager = new UnitManager(); categoryManager = new CategoryManager(); manufacturerManager = new ManufacturerManager(); countryManager = new CountryManager(); providerManager = new ProviderManager(); // MODE = Constants.MODE.ADD; }
// Use this for initialization protected void Start () { //Here be dragons um = GameObject.FindObjectOfType<UnitManager>(); em = GameObject.FindObjectOfType<EnemyManager>(); LADDERINDEX = TileSpecList.getTileSpecInt("Ladder"); currentMovement = new Vector2(0,0); map = GameObject.FindObjectOfType<Map>(); currentState = movementState.IDLE; //Start the pathing coroutine StartCoroutine(getPath()); StartCoroutine(computeState()); cc = GetComponent<CharacterController>(); position = new Vector2(Mathf.RoundToInt(this.transform.position.x),Mathf.RoundToInt(this.transform.position.y)); selected = false; this.transform.localScale = new Vector3(size,size,size); this.right = Random.value>.5f; }
void Start() { UM = gameObject.GetComponent<UnitManager>(); camera = GetComponent<Camera>(); }
public void TriggeredStart() { Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto); Enum.TryParse(SceneManager.GetActiveScene().name, out state); if (state == SceneState.Title) { hostInputField = GameObject.Find("HostInputField").GetComponent <TMP_InputField>(); portInputField = GameObject.Find("PortInputField").GetComponent <TMP_InputField>(); hostInputField.text = GetYAMLObject(@"YAML\ClientConfig.yml").GetData <string>("Host"); portInputField.text = GetYAMLObject(@"YAML\ClientConfig.yml").GetData <int>("Port").ToString(); GameObject.Find("Button").GetComponent <Button>().onClick.AddListener(ConnectClick); successImage = GameObject.Find("Button").transform.Find("Background").Find("SuccessImage").gameObject; successTimer = 0; blackScreen = GameObject.Find("BlackScreen").GetComponent <Image>(); applyPlayerSelectObj = false; playerSelectObj = null; } else if (state == SceneState.Lobby) { RectTransform iconRoot = GameObject.Find("IconRoot").GetComponent <RectTransform>(); int count = 0; Vector2 initPos = new Vector2(32f, -32f); foreach (UnitType type in Enum.GetValues(typeof(UnitType))) { if (type >= UnitType.HatsuneMiku) { int x = count % 8; int y = count / 8; GameObject instance = Instantiate(championSelectIconPrefab, iconRoot); instance.GetComponent <RectTransform>().anchorMin = new Vector2(0, 1); instance.GetComponent <RectTransform>().anchorMax = new Vector2(0, 1); instance.GetComponent <RectTransform>().pivot = new Vector2(0, 1); instance.GetComponent <RectTransform>().anchoredPosition = initPos + new Vector2(x * 100, y * -100); instance.GetComponent <ChampionSelectIcon>().SetData(type, this); count++; } } lobbyTitle = GameObject.Find("LobbyTitle").GetComponent <Text>(); blueContentRectTransform = GameObject.Find("BlueContent").GetComponent <RectTransform>(); redContentRectTransform = GameObject.Find("RedContent").GetComponent <RectTransform>(); selectedChampionIconImage = GameObject.Find("SelectedChampionIconImage").GetComponent <Image>(); nameInputField = GameObject.Find("NameInputField").GetComponent <InputField>(); setNameButton = GameObject.Find("SetNameButton").GetComponent <Button>(); GameObject.Find("SetNameButton").GetComponent <Button>().onClick.AddListener(SetNameButtonPressed); teamButton = GameObject.Find("TeamButton").GetComponent <Button>(); GameObject.Find("TeamButton").GetComponent <Button>().onClick.AddListener(SetTeamButtonPressed); readyButton = GameObject.Find("ReadyButton").GetComponent <Button>(); GameObject.Find("ReadyButton").GetComponent <Button>().onClick.AddListener(ReadyButtonPressed); chatUI = GameObject.Find("ChatUI").GetComponent <ChatUI>(); chatUI.SetClientNetwork(client); GameObject.Find("SendButton").GetComponent <Button>().onClick.AddListener(chatUI.Send); if (!applyPlayerSelectObj && playerSelectObj != null) { type = playerSelectObj.Type; SetUnitTypeIcon(type); _name = playerSelectObj.Name; nameInputField.text = playerSelectObj.Name; _team = playerSelectObj.Team; SetTeamButtonColor(_team); _ready = playerSelectObj.Ready; SetReadyButtonColor(_ready); applyPlayerSelectObj = true; playerSelectObj = null; } } else { unitManager = GameObject.Find("UnitManager").GetComponent <UnitManager>(); chatUI = GameObject.Find("ChatUI").GetComponent <ChatUI>(); chatUI.SetClientNetwork(client); applyPlayerSelectObj = false; playerSelectObj = null; } }
public UnitFactoryBuilder() { _instanceManager = new GameObject().AddComponent <UnitManager>(); _parentTransform = _instanceManager.transform; }
public AIManager(UnitManager unitManager) { this.unitManager = unitManager; }
void Start() { moveSpeed = 7.0f; navMeshAgent = GetComponent <NavMeshAgent>(); unitManager = GameObject.FindGameObjectWithTag("PlayerUnitManager").GetComponent <UnitManager>(); }
void Awake() { _unitManager = GameObject.Find("PlayerUnitManager").GetComponent <UnitManager>(); _animation = GetComponent <Animation>(); _agent = GetComponent <NavMeshAgent>(); }
void Awake() { i = this; }
void Awake() { buildManager = BuildManager.instance; unitManager = UnitManager.instance; }
public override void Act(UnitManager manager, Unit actingUnit) { manager.BeginCastingAbility(actingUnit, targetUnit.unit.currentTile, abilityToUse); }
public override void Act(UnitManager manager, Unit actingUnit) { manager.AttackTile(targetUnit.unit.transform); }
public override void Act(UnitManager manager, Unit actingUnit) { manager.RequestPath(tileToMoveTo.transform); }
public virtual void Act(UnitManager manager, Unit actingUnit) { }
// Use this for initialization void Start() { Vector3 pos = transform.position; pos.y += sumToY; weapon = Instantiate(weapon, pos, transform.rotation) as AbstractWeapon; unitManager = GameObject.FindWithTag("UnitManager").GetComponent<UnitManager>(); }
private void Awake() { instance = this; }
/// <summary> /// Calculates the amount of production that will be generated for the given production at this city /// This takes modifiers into account /// </summary> /// <param name="production"></param> /// <param name="buildingManager"></param> /// <param name="unitManager"></param> /// <returns></returns> public int GetProductionIncome(Production production, BuildingManager buildingManager, UnitManager unitManager) { float prodIncome = 0f; // calculate production this turn switch (production.ProductionType) { case ProductionType.UNIT: Unit u = unitManager.GetUnit(production.Name); prodIncome = IncomeProduction; if (u.Tags.Contains("MILITARY")) { prodIncome *= MilitaryProductionModifier; } if (u.Tags.Contains("SPACESHIP")) { prodIncome *= SpaceProductionModifier; } break; case ProductionType.BUILDING: Building b = buildingManager.GetBuilding(production.Name); prodIncome = IncomeProduction; prodIncome *= BuildingProductionModifier; if (b.Tags.Contains("WONDER")) { prodIncome *= WonderProductionModifier; } break; } return((int)prodIncome); }
static void Main(string[] args) { //Decimal d = 3.0000M; //Console.WriteLine(Decimal.Divide(Decimal.MaxValue, 19M)); //Console.WriteLine(Decimal.Divide((decimal)277, (decimal)19).ToString("E3")); //Console.WriteLine("Rounding: " + Decimal.Round((decimal)0.123456789, decimals: 5)); ////decimal.TryParse("678E+002", out d); //Console.WriteLine("d=" + d); //var sci = new ScientificDecimal(); //sci = 12345.67890987654321; //Console.WriteLine(sci.Value); //Console.WriteLine(sci.DecimalValue); //float f = (float)sci.Coefficient; //sci.Round(4); //Console.WriteLine(sci.Value); //Console.WriteLine(sci.DecimalValue); //Console.WriteLine("MaxValue: " + Decimal.MaxValue); //Console.WriteLine("MinValue: " + Decimal.MinValue); //Console.WriteLine("================================================================="); //var rxi = new Rounding(new ExtraInfo(new Unit())); UnitManager mgr = new UnitManager(); //UnitManager<Rounding> mgr = new UnitManager<Rounding>(); double ddd; var su = double.TryParse("3.4m", out ddd); while (true) { Console.WriteLine("Enter value and unit (for example 3.4m):"); string inputstr = Console.ReadLine(); inputstr = inputstr.Trim(); if (string.IsNullOrEmpty(inputstr)) { return; } double number; string symbol; bool success = TryParseUnit(inputstr, out number, out symbol); IUnit srcUnit = mgr.Units.FirstOrDefault(p => p.Symbol.Equals(symbol, StringComparison.InvariantCultureIgnoreCase)); if (srcUnit == null) { Console.WriteLine(string.Format("{0} was not recognized as a valid input. Press enter to quit.", inputstr)); Console.WriteLine(); Console.WriteLine(); continue; } srcUnit.Magnitude = number; Console.WriteLine("places before decimal point: " + srcUnit.PlacesBeforeDecimalPoint()); Console.WriteLine("places after decimal point: " + srcUnit.DecimalPlaces()); //IUnit foot = mgr.Units.FirstOrDefault(p => p.Name == "Foot"); ////foot.Magnitude = 10; //foot.Magnitude = 10.123456789; //foot.Magnitude = 0.00123456789; //try { // foot.Magnitude = Convert.ToDouble("20e+4"); //} catch { // Console.Read(); //} //foot.Magnitude = 10000000000000000000000000000; //foot.Magnitude = 79228162514264337593543950335; //mgr.UpdateUnits(foot); mgr.UpdateUnits(srcUnit); Console.WriteLine(); foreach (var unit in mgr.Units) { if (unit.Magnitude.HasValue) { Console.WriteLine("{0}:\t{1}{2}", unit.Plural(), unit.Magnitude, unit.Symbol); //Console.WriteLine("{0}:\t{1}{2} (rounded)", unit.Plural(), unit.RoundedValue(2), unit.Symbol); var roundToDecimalPlaces = srcUnit.DecimalPlaces() + 4; if (roundToDecimalPlaces < 0) { roundToDecimalPlaces = 0; } if (roundToDecimalPlaces > 15) { roundToDecimalPlaces = 15; } var scientificNotation = unit.ToScientificNotation(roundToDecimalPlaces); Console.WriteLine("{0}:\t{1}e{2} {3}", unit.Plural(), scientificNotation.Coefficient, scientificNotation.Exponent, unit.Symbol); Console.WriteLine("{0}:\t{1}{2}", unit.Plural(), scientificNotation.ToDouble(), unit.Symbol); } else { Console.WriteLine("{0}:\t(no value)", unit.Name); } Console.WriteLine(); } } //Console.WriteLine("................................................"); //var r = new Rounding(mgr.Units.First()); //r.Value = 1234.56789M; //r.Round(2); //Console.WriteLine(r.Value); //Console.WriteLine(r.RoundedValue); Console.Read(); }
public Sphinx3Loader(string location, UnitManager unitManager, float distFloor, float mixtureWeightFloor, float varianceFloor, int topGauNum, bool useCDUnits) { this.calculatedCheckSum = 0L; this.init(ConfigurationManagerUtils.resourceToURL(location), unitManager, distFloor, mixtureWeightFloor, varianceFloor, topGauNum, useCDUnits, Logger.getLogger(Object.instancehelper_getClass(this).getName())); }
// Start is called before the first frame update protected virtual void Start() { this.capturedEntities = new List <CaptureEntity>(); boardManager = FindObjectOfType <BoardManager>(); unitManager = FindObjectOfType <UnitManager>(); }
protected override void Awake() { base.Awake(); unitManager = FindObjectOfType <UnitManager>(); }
void Awake() { Instance = this; }
// Use this for initialization void Start() { player = GetComponent<Player>(); m_power = GetComponent<PowerManager>(); m_tiles = GameObject.FindGameObjectWithTag("GameController").GetComponent<TileManager>(); m_units = GameObject.FindGameObjectWithTag("GameController").GetComponent<UnitManager>(); m_hud = GameObject.FindGameObjectWithTag("GameController").GetComponent<HUDManager>(); tilesInPower = new List<Tile>(); unitsInPower = new List<Unit>(); }
void Start() { GameObject unitManagerObject = GameObject.FindGameObjectWithTag("PlayerUnitManager"); unitManager = unitManagerObject.GetComponent<UnitManager>(); }
void Start() { unitManger = GameObject.FindGameObjectWithTag ("PlayerUnitManager").GetComponent<UnitManager> (); }
void Awake() { sInstance = this; this.UnitTable = new Dictionary <UnitForce, List <UnitState> >(); }
public TranscriptHMMGraph(string context, Transcript transcript, AcousticModel acousticModel, UnitManager unitManager) { BuildTranscriptHMM buildTranscriptHMM = new BuildTranscriptHMM(context, transcript, acousticModel, unitManager); this.copyGraph(buildTranscriptHMM.getGraph()); }
public BattleEndCheckCommand(WorldModel worldModel, HistoryManager historyManager, UnitManager unitManager, ProjectileManager projectileManager, CommandProcessor commandProcessor ) { _worldModel = worldModel; _commandProcessor = commandProcessor; _commandProcessor.AddLateCommand(this); }
void Awake() { _unit = GetComponent <Unit>(); _unitManager = GameObject.Find("PlayerUnitManager").GetComponent <UnitManager>(); }
void Awake() { manager = UnitManager.getInstance(); }
void Start() { unitManager = GameObject.FindGameObjectWithTag("PlayerUnitManager").GetComponent <UnitManager>(); }
void Start() { parentPanel = GameObject.Find("Panel Units").GetComponent<RectTransform>(); unitPanel = GameObject.Find("Unit Panel").GetComponent<Menu>(); unitRenderScript = GameObject.Find("Unit Panel").GetComponent<UnitPanelRender>(); battlePanel = GameObject.Find("Battle Panel").transform; dragScript = battlePanel.GetComponent<DragScript>(); parentDragPanel = GameObject.Find("Panel DragUnits").transform; unitManager = GameObject.Find("UnitsData").GetComponent<UnitManager>(); renamePanel = GameObject.Find("Rename Panel").transform; CloseRenamePanel(); skillPanel = GameObject.Find("Skill Panels").transform; assaultScript = GameObject.Find("AssaultGO").GetComponent<AssaultClass>(); defenderScript = GameObject.Find("DefenderGO").GetComponent<DefenderClass>(); medicScript = GameObject.Find("MedicGO").GetComponent<MedicClass>(); //Set up R&D buttons/text when scene is loaded rDManager = GameObject.Find("UnitsData").GetComponent<RDManager>(); renderData("R&D Panel"); }
// This coroutine makes the current unit make an attack public IEnumerator AttackAction(UnitClass targetUnit) { // currently this attack targets 1 enemy unit // Vars UnityEngine.UI.Text attackText = UIManager.instance.attackPanel.transform.GetChild(1).GetComponent <UnityEngine.UI.Text>(); string resultString; // UI layer ClearPath(); cursor.SetActive(false); waitForUI = true; EventManager.TriggerEvent("Wait For UI"); // UIManager.instance.attackPanel.SetActive( false); //Rotate unit float targetAngle = UnitManager.FindFacing(currentUnit.UnitGO.transform, targetUnit.UnitGO.transform); Debug.Log("Rotate me this much: " + Mathf.Round(targetAngle / 90f) * 90f); Transform curT = currentUnit.UnitGO.transform; curT.rotation = Quaternion.Euler(new Vector3(curT.rotation.x, Mathf.Round(targetAngle / 90f) * 90f, curT.rotation.z)); float angle = UnitManager.FindFacing(currentUnit.UnitGO.transform, targetUnit.UnitGO.transform); Debug.Log("Facing target's: " + UnitManager.FacingDirection(targetUnit, currentUnit)); Debug.Log("" + angle); // Attack and damage calculation if (UnitManager.instance.RollAttack(currentUnit, targetUnit) == true) { // Do damage int damage = currentUnit.Damage; Debug.Log("Attack damage: " + damage); targetUnit.CurrentHealth -= damage; resultString = "Hit! \r\n" + currentUnit.Name + " strikes " + targetUnit.Name + "!"; resultString += "\r\n" + damage + " damage!"; // Check if enemy has been defeated if (targetUnit.CurrentHealth <= 0) { resultString += "\r\n"; resultString += "\r\n"; resultString += targetUnit.Name += " has been slain!"; UnitManager.instance.UnitKilled(targetUnit); } } else { // Miss! Debug.Log("Attack: Miss!"); resultString = "Miss! \r\n" + targetUnit.Name + " dodges " + currentUnit.Name + "!"; } // UIManager show results ( string "unit a strikes unit b x damage", wait attackTimer ) UIManager.instance.attackPanel.SetActive(true); attackText.text = resultString; yield return(new WaitForSeconds(UIManager.instance.messageTimer)); UIManager.instance.attackPanel.SetActive(false); waitForUI = false; EventManager.TriggerEvent("Wait For UI"); HighLightCell(currentUnit.Cell); InspectorActionText(); UIManager.instance.CurrentUnitHUD(); //Check win condition EndCondition(); yield return(null); }
public static UnitManager getInstance() { if(instance == null) instance = (UnitManager)FindObjectOfType(typeof(UnitManager)); return instance; }
void Start() { unitManager = Toolbox.GetScript <UnitManager>(); }
// read variables from XLSX mapping file for only one dataset //public System.Data.DataTable readVariables(string filePath, string dataSetID, System.Data.DataTable mappedAttributes, System.Data.DataTable mappedUnits) //{ // string mappingFile = filePath + @"\variableMapping.xlsx"; // string sheetName = "mapping"; // long startRow = 2; // long endRow = startRow; // System.Data.DataTable mappedVariables = new System.Data.DataTable(); // mappedVariables.Columns.Add("DatasetId", typeof(string)); // mappedVariables.Columns.Add("Name", typeof(string)); // mappedVariables.Columns.Add("Description", typeof(string)); // mappedVariables.Columns.Add("Block", typeof(int)); // mappedVariables.Columns.Add("Attribute", typeof(string)); // mappedVariables.Columns.Add("Unit", typeof(string)); // mappedVariables.Columns.Add("ConvFactor", typeof(string)); // mappedVariables.Columns.Add("AttributeId", typeof(long)); // mappedVariables.Columns.Add("UnitId", typeof(long)); // mappedVariables.Columns.Add("VarUnitId", typeof(long)); // excel_init(mappingFile, sheetName, startRow, ref endRow); // for (long i = startRow; i < endRow; i++) // { // System.Data.DataRow newRow = mappedVariables.NewRow(); // if (getValue(i.ToString(), "A") == dataSetID) // { // newRow["DatasetId"] = getValue(i.ToString(), "A"); // newRow["Name"] = getValue(i.ToString(), "B"); // newRow["Description"] = getValue(i.ToString(), "E"); // string AttributeShortName = getValue(i.ToString(), "F"); // newRow["Attribute"] = AttributeShortName; // string variableUnit = getValue(i.ToString(), "G"); // newRow["Unit"] = variableUnit; // newRow["ConvFactor"] = getValue(i.ToString(), "H"); // newRow["Block"] = int.Parse(getValue(i.ToString(), "I")); // if (AttributeShortName.Length > 1) // if not mapped yet // { // // select related attribute as row from mappedAttributes Table // System.Data.DataRow mappedAttributesRow = mappedAttributes.Select("ShortName = '" + AttributeShortName + "'").First<System.Data.DataRow>(); // // add related attributeId and unitId to the mappedVariables Table // newRow["AttributeId"] = Convert.ToInt64(mappedAttributesRow["AttributeId"]); // newRow["UnitId"] = Convert.ToInt64(mappedAttributesRow["UnitId"]); // } // if (variableUnit.Length > 0) // if dimensioned // { // // select related unit as row of mappedUnits // System.Data.DataRow mappedUnitsRow = mappedUnits.Select("Abbreviation = '" + variableUnit + "'").First<System.Data.DataRow>(); // // add related UnitId of variable Unit to the mappedVariables Table // newRow["VarUnitId"] = Convert.ToInt64(mappedUnitsRow["UnitId"]); // } // mappedVariables.Rows.Add(newRow); // } // } // newWorkbook.Close(); // return mappedVariables; //} // read variables from XLSX mapping file //public System.Data.DataTable readVariables(string filePath, System.Data.DataTable mappedAttributes, System.Data.DataTable mappedUnits) //{ // string mappingFile = filePath + @"\variableMapping.xlsx"; // string sheetName = "mapping"; // long startRow = 2; // long endRow = startRow; // System.Data.DataTable mappedVariables = new System.Data.DataTable(); // mappedVariables.Columns.Add("DatasetId", typeof(string)); // mappedVariables.Columns.Add("Name", typeof(string)); // mappedVariables.Columns.Add("Description", typeof(string)); // mappedVariables.Columns.Add("Block", typeof(int)); // mappedVariables.Columns.Add("Attribute", typeof(string)); // mappedVariables.Columns.Add("Unit", typeof(string)); // mappedVariables.Columns.Add("ConvFactor", typeof(string)); // mappedVariables.Columns.Add("AttributeId", typeof(long)); // mappedVariables.Columns.Add("UnitId", typeof(long)); // mappedVariables.Columns.Add("VarUnitId", typeof(long)); // excel_init(mappingFile, sheetName, startRow, ref endRow); // for (long i = startRow; i < endRow; i++) // { // System.Data.DataRow newRow = mappedVariables.NewRow(); // newRow["DatasetId"] = getValue(i.ToString(), "A"); // newRow["Name"] = getValue(i.ToString(), "B"); // newRow["Description"] = getValue(i.ToString(), "E"); // string AttributeShortName = getValue(i.ToString(), "F"); // newRow["Attribute"] = AttributeShortName; // string variableUnit = getValue(i.ToString(), "G"); // newRow["Unit"] = variableUnit; // newRow["ConvFactor"] = getValue(i.ToString(), "H"); // newRow["Block"] = int.Parse(getValue(i.ToString(), "I")); // if (AttributeShortName.Length > 1) // if not mapped yet // { // // select related attribute as row from mappedAttributes Table // System.Data.DataRow mappedAttributesRow = mappedAttributes.Select("ShortName = '" + AttributeShortName + "'").First<System.Data.DataRow>(); // // add related attributeId and unitId to the mappedVariables Table // newRow["AttributeId"] = Convert.ToInt64(mappedAttributesRow["AttributeId"]); // newRow["UnitId"] = Convert.ToInt64(mappedAttributesRow["UnitId"]); // } // if (variableUnit.Length > 0) // if dimensioned // { // // select related unit as row of mappedUnits // System.Data.DataRow mappedUnitsRow = mappedUnits.Select("Abbreviation = '" + variableUnit + "'").First<System.Data.DataRow>(); // // add related UnitId of variable Unit to the mappedVariables Table // newRow["VarUnitId"] = Convert.ToInt64(mappedUnitsRow["UnitId"]); // } // mappedVariables.Rows.Add(newRow); // } // newWorkbook.Close(); // return mappedVariables; //} /// <summary> /// read attributes from csv file /// </summary> /// <param name="filePath"></param> /// <param name="mappedUnits"></param> /// <param name="mappedDataTypes"></param> /// <returns></returns> public System.Data.DataTable readAttributes(string filePath) { string mappingFile = filePath + @"\variableMapping.xlsx"; System.Data.DataTable mappedAttributes = new System.Data.DataTable(); mappedAttributes.Columns.Add("Name", typeof(string)); mappedAttributes.Columns.Add("ShortName", typeof(string)); mappedAttributes.Columns.Add("Description", typeof(string)); mappedAttributes.Columns.Add("IsMultipleValue", typeof(string)); mappedAttributes.Columns.Add("IsBuiltIn", typeof(string)); mappedAttributes.Columns.Add("Owner", typeof(string)); mappedAttributes.Columns.Add("ContainerType", typeof(string)); mappedAttributes.Columns.Add("MeasurementScale", typeof(string)); mappedAttributes.Columns.Add("EntitySelectionPredicate", typeof(string)); mappedAttributes.Columns.Add("Self", typeof(string)); mappedAttributes.Columns.Add("DataType", typeof(string)); mappedAttributes.Columns.Add("Unit", typeof(string)); mappedAttributes.Columns.Add("Methodology", typeof(string)); mappedAttributes.Columns.Add("Constraints", typeof(string)); mappedAttributes.Columns.Add("ExtendedProperties", typeof(string)); mappedAttributes.Columns.Add("GlobalizationInfos", typeof(string)); mappedAttributes.Columns.Add("AggregateFunctions", typeof(string)); mappedAttributes.Columns.Add("DataTypeId", typeof(long)); mappedAttributes.Columns.Add("UnitId", typeof(long)); mappedAttributes.Columns.Add("AttributeId", typeof(long)); if (File.Exists(filePath + "\\attributes.csv") && File.Exists(filePath + "\\datatypes.csv") && File.Exists(filePath + "\\units.csv")) { using (StreamReader reader = new StreamReader(filePath + "\\attributes.csv")) { string line = ""; //jump over the first row line = reader.ReadLine(); UnitManager unitManager = null; DataTypeManager dataTypeManager = null; try { unitManager = new UnitManager(); dataTypeManager = new DataTypeManager(); while ((line = reader.ReadLine()) != null) { // (char)59 = ';' string[] vars = line.Split((char)59); System.Data.DataRow newRow = mappedAttributes.NewRow(); newRow["Name"] = vars[0]; newRow["ShortName"] = vars[1]; newRow["Description"] = vars[2]; newRow["IsMultipleValue"] = vars[3]; newRow["IsBuiltIn"] = vars[4]; newRow["Owner"] = vars[5]; newRow["ContainerType"] = vars[6]; newRow["MeasurementScale"] = vars[7]; newRow["EntitySelectionPredicate"] = vars[8]; newRow["Self"] = vars[9]; string DataType = vars[10]; newRow["DataType"] = DataType; string UnitAbbreviation = vars[11]; newRow["Unit"] = UnitAbbreviation; newRow["Methodology"] = vars[12]; newRow["Constraints"] = vars[13]; newRow["ExtendedProperties"] = vars[14]; newRow["GlobalizationInfos"] = vars[15]; newRow["AggregateFunctions"] = vars[16]; // add DataTypesId and UnitId to the mappedAttributes Table newRow["DataTypeId"] = dataTypeManager.Repo.Get().Where(dt => dt.Name.ToLower().Equals(DataType.ToLower())).FirstOrDefault().Id; Unit unit = unitManager.Repo.Get().Where(u => u.Abbreviation.Equals(UnitAbbreviation)).FirstOrDefault(); if (unit != null) { newRow["UnitId"] = unitManager.Repo.Get().Where(u => u.Abbreviation.Equals(UnitAbbreviation)).FirstOrDefault().Id; } else { newRow["UnitId"] = 1; } mappedAttributes.Rows.Add(newRow); } } finally { unitManager.Dispose(); dataTypeManager.Dispose(); } } } return(mappedAttributes); }
public void Shutdown() { Destroy(instance.gameObject); instance = null; }
// Use this for initialization void Start() { // To prevent duplicate unitManagers if (unitManagerRef == null) { unitManagerRef = this; DontDestroyOnLoad(gameObject); nameSelector = GetComponent<NameSelector>(); tileManager = GetComponent<TileManager>(); tileInfo = GameObject.Find("Tile Info"); initGameData(); // Create or load data depending on option clicked } // Destroy duplicated gameObject created when changing scenes else DestroyImmediate(gameObject); }
void Awake() { bm = BuildManager.instance; um = UnitManager.instance; }
void Awake() { unitManager = FindObjectOfType <UnitManager> (); unitToPortraitMap = new Dictionary <Unit, UnitPortrait> (); displayedUnits = new List <Unit> (); }
void Awake() { instance = this; Selected = null; }