protected virtual GameObject SpawnObject(bool initial = false, int index = 0) { if (_objectsToPool.Length <= 0) { Supporting.Log("No objects defined to create pool", 1); return(null); } // if spawning initial objects, spawn the selected one int selectedObject = index; // else, spawn one at random, assuming there's more than one option if (!initial) { if (_objectsToPool.Length > 1) { selectedObject = Random.Range(0, _objectsToPool.Length); } } // instantiate a new inactive object, adding it to the pool for later usage GameObject obj = (GameObject)Instantiate(_objectsToPool[selectedObject]); obj.SetActive(false); _pooledObjects.Add(obj); return(obj); }
private static void DownloadCSV(string tabID, string filePath) { //Get the formatted URL string downloadUrl = string.Format(URL_FORMAT, SPREADSHEET_ID, tabID); // Supporting.Log(string.Format("Downloading {0} to {1}", tabID, filePath)); //Download the data WWW website = new WWW(downloadUrl); //Wait for data to download while (!website.isDone) { } if (!string.IsNullOrEmpty(website.error)) { Supporting.Log(website.error, 1); // cached values are automatically pulled by the clients, based on what was last writen to the filepath // Supporting.Log("Using cached values instead"); } else { //Successfully got the data, process it //Save to disk File.WriteAllText(filePath, website.text); } }
private void Start() { Supporting.CheckRequiredProperty(gameObject, _canvas, "Canvas"); Supporting.CheckRequiredProperty(gameObject, _display, "Display"); Supporting.CheckRequiredProperty(gameObject, _statusNodesIdle, "StatusNodeIdle"); Supporting.CheckRequiredProperty(gameObject, _statusNodesCorrect, "StatusNodeCorrect"); Supporting.CheckRequiredProperty(gameObject, _statusNodesWrong, "StatusNodeWrong"); Supporting.CheckRequiredProperty(gameObject, _btn0, "Button 0"); Supporting.CheckRequiredProperty(gameObject, _btn1, "Button 1"); Supporting.CheckRequiredProperty(gameObject, _btn2, "Button 2"); Supporting.CheckRequiredProperty(gameObject, _btn3, "Button 3"); Supporting.CheckRequiredProperty(gameObject, _btn4, "Button 4"); Supporting.CheckRequiredProperty(gameObject, _btn5, "Button 5"); Supporting.CheckRequiredProperty(gameObject, _btn6, "Button 6"); Supporting.CheckRequiredProperty(gameObject, _btn7, "Button 7"); Supporting.CheckRequiredProperty(gameObject, _btn8, "Button 8"); Supporting.CheckRequiredProperty(gameObject, _btn9, "Button 9"); Supporting.CheckRequiredProperty(gameObject, _btnEnter, "Button Enter"); Supporting.CheckRequiredProperty(gameObject, _btnBack, "Button Back"); Supporting.CheckRequiredProperty(gameObject, _btnExit, "Button Exit"); Supporting.CheckRequiredProperty(gameObject, _audioSource, "AudioSource"); _defaultColor = display.color; BindButtons(); }
private void Update() { if (!_ready) { return; } if (!_target && GameManager.instance) { GameObject player = GameManager.instance.player; if (player) { _target = player.transform; } } if (_debug || _debugAll) { if (Input.GetKeyDown(KeyCode.Alpha0)) { Supporting.Log(string.Format("Enemy is in state {0}", currentState), 2); Debug.Break(); } } _anim.SetFloat(AnimationParameters.Speed.ToString(), _navMeshAgent.velocity.magnitude * 0.2f); stateManager.Update(); if (GameManager.instance.gameOver) { ShutDown(); } }
public string DeleteUserSQL(string username) { string cmdStr = " DELETE a FROM Transactions a " + " INNER JOIN Accounts b ON a.Account_Id = b.Id " + " WHERE b.username = @username;" + " DELETE FROM Accounts " + " WHERE username = @username;" + " DELETE FROM UserInstitution " + " WHERE username = @username;" + " DELETE FROM Users " + " WHERE username = @username;"; SqlCommand command = new SqlCommand(cmdStr, SQLraw); command.Parameters.AddWithValue("@username", username); try { command.ExecuteNonQuery(); } catch (Exception e) { Supporting.WriteLog(e.ToString()); return("error: delete failed"); } return("info: success"); }
public bool DataExists(SQLData data) { int result = 0; string cmdStr = "SELECT COUNT(*) AS count FROM data " + "WHERE LOWER(user_id) = @user AND time = @time AND (mean = @mean OR median = @median OR std_dev = @std_dev OR count = @count) ;"; SqlCommand command = new SqlCommand(cmdStr, SQLraw); command.Parameters.AddWithValue("@user", data.User); command.Parameters.AddWithValue("@time", data.Time); command.Parameters.AddWithValue("@mean", data.Mean); command.Parameters.AddWithValue("@median", data.Median); command.Parameters.AddWithValue("@std_dev", data.StdDev); command.Parameters.AddWithValue("@count", data.Count); SqlDataReader reader = null; try { reader = command.ExecuteReader(); while (reader.Read()) { result = Convert.ToInt32(reader["count"]); } reader.Close(); } catch (Exception e) { Supporting.WriteLog(e.Message); return(true); } return(result == 0 ? false : true); }
/// <summary> /// Initializes a new instance of the <see cref="T:XRay.XRayable"/> class. /// </summary> /// <param name="target">Target.</param> public XRayable(GameObject target, XRay owner) { Enemy enemy = target.GetComponent <Enemy>(); _targetTransform = target.transform; _owner = owner; if (!enemy) { Supporting.Log(string.Format("Can't Xray {0} as it's not an enemy", 1)); } _targetRenderers = enemy.xRayAffectedMeshes; if (_targetRenderers.Length > 0) { foreach (Renderer renderer in _targetRenderers) { if (renderer) { ApplyXRayEffect(renderer); } else { throw new ArgumentNullException(string.Format("Renderer not found for {0}", _targetTransform.name)); } } } else { throw new ArgumentNullException(string.Format("Renderer not found for {0}", _targetTransform.name)); } }
private string InsertData(SQLData data) { string cmdStr = " INSERT INTO data (user_id, time_zone, time, active, count, mean, median, std_dev) " + " VALUES (@user , @time_zone, @time , @active, @count, @mean, @median, @std_dev);"; SqlCommand command = new SqlCommand(cmdStr, SQLraw); command.Parameters.AddWithValue("@user", data.User); command.Parameters.AddWithValue("@time_zone", data.TimeZone); command.Parameters.AddWithValue("@time", data.Time); command.Parameters.AddWithValue("@active", data.Active); command.Parameters.AddWithValue("@count", data.Count); command.Parameters.AddWithValue("@mean", data.Mean); command.Parameters.AddWithValue("@median", data.Median); command.Parameters.AddWithValue("@std_dev", data.StdDev); try { command.ExecuteNonQuery(); } catch (Exception e) { Supporting.WriteLog(e.Message); return("error: adding data"); } return("info: added data"); }
private void RunInitialChecks() { _renderer = GetComponent <SpriteRenderer>(); Supporting.CheckRequiredProperty(gameObject, _renderer, "Spirte Renderer"); Supporting.CheckRequiredProperty(gameObject, _wind, "Wind"); }
public void IdleOnUpdate() { if (_debugAll) { Supporting.Log(string.Format("{0} is in Idle State", gameObject.name), gameObject); } _aiIdle.UpdateIdle(); }
private void RunInitialChecks() { Supporting.CheckRequiredProperty(gameObject, _shrinked, "Shrinked Sprite"); Supporting.CheckRequiredProperty(gameObject, _expanded, "Expanded Sprite"); _collider = GetComponent <BoxCollider2D>(); Supporting.CheckRequiredProperty(gameObject, _collider, "Collider"); }
private void RunInitialChecks() { Supporting.CheckRequiredProperty(gameObject, _rb, "Rigidboy"); Supporting.CheckRequiredProperty(gameObject, _gapCheck, "Gap Check"); Supporting.CheckRequiredProperty(gameObject, _floorCheck, "Jump Level Check"); Supporting.CheckRequiredProperty(gameObject, _landingCheck, "Jump High Check"); Supporting.CheckRequiredProperty(gameObject, _runnerAnimator, "Runner Animator"); }
public void IdleOnExit() { if (_debug || _debugAll) { Supporting.Log(string.Format("{0} is exiting Idle State", gameObject.name), gameObject); } _anim.SetBool(AnimationParameters.IdleState.ToString(), false); _aiIdle.ExitIdle(); }
public static void Initialize() { // Supporting.Log("GameData.Constants is initializing"); _constants = new Dictionary <string, object>(); // fetch the data GameData.Downloader.DownloadConstants(); //Now load using System.IO File. StreamReader csv = File.OpenText(filePath); // break the csv into rows string[] rows = csv.ReadToEnd().Split('\n'); for (int i = 1; i < rows.Length; i++) { string[] columns = rows[i].Split(','); string key = columns[0].Trim(); string type = columns[1].Trim(); string value = columns[2].Trim(); if (type == INT_KEY) { int iValue; if (int.TryParse(value, out iValue)) { _constants.Add(key, iValue); } else { Supporting.Log(string.Format("Couldn't parse data for {0}", key), 1); } } else if (type == FLOAT_KEY) { float fValue; if (float.TryParse(value, out fValue)) { _constants.Add(key, fValue); } else { Supporting.Log(string.Format("Couldn't parse data for {0}", key), 1); } } else if (type == STRING_KEY) { _constants.Add(key, value); } else { Supporting.Log(string.Format("Couldn't resolve constant type for {0}", key), 1); } } }
public void PatrolOnExit() { if (_debug || _debugAll) { Supporting.Log(string.Format("{0} is exiting Patrol State", gameObject.name), gameObject); } _aiPatrol.ExitPatrol(); }
public void PatrolOnUpdate() { if (_debugAll) { Supporting.Log(string.Format("{0} is in Patrol State", gameObject.name), gameObject); } _aiPatrol.UpdatePatrol(); }
// [THISSHIT] [TH] - QUESTION - WTF? public void FinishRecover() { if (_debugAll) { Supporting.Log(string.Format("{0} finished recovered", gameObject.name), gameObject); } idle(); }
public void SearchOnUpdate() { if (_debugAll) { Supporting.Log(string.Format("{0} is in Search State", gameObject.name), gameObject); } _aiSearch.UpdateSearch(); }
public void Recover() { if (_debugAll) { Supporting.Log(string.Format("{0} recovered", gameObject.name), gameObject); } recover(); }
public void SearchOnExit() { if (_debug || _debugAll) { Supporting.Log(string.Format("{0} is exiting Search State", gameObject.name), gameObject); } _aiSearch.ExitSearch(); }
public void AttackOnExit() { if (_debug || _debugAll) { Supporting.Log(string.Format("{0} is exiting Attack State", gameObject.name), gameObject); } _anim.SetBool(AnimationParameters.AttackState.ToString(), false); _aiAttack.ExitAttack(); }
public void StunnedOnUpdate() { if (_debugAll) { Supporting.Log(string.Format("{0} is in Stunned State", gameObject.name), gameObject); } _aiStunned.UpdateStun(); }
public void AttackOnUpdate() { if (_debugAll) { Supporting.Log(string.Format("{0} is in Attack State", gameObject.name), gameObject); } _aiAttack.UpdateAttack(); }
public void ChaseOnExit() { if (_debug || _debugAll) { Supporting.Log(string.Format("{0} is exiting Chase State", gameObject.name), gameObject); } _aiChase.ExitChase(); }
public void ChaseOnUpdate() { if (_debugAll) { Supporting.Log(string.Format("{0} is in Chase State", gameObject.name), gameObject); } _aiChase.UpdateChase(); }
private void RunInitialChecks() { // Find the player _target = GameController.instance.character; if (Supporting.CheckRequiredProperty(gameObject, _target, "Target")) { _offset = _target.position.x - transform.position.x; } }
private void ApplyXRayEffect(Renderer renderer) { renderer.material.SetFloat("_XOpacity", 1); if (renderer.material.GetFloat("_XLength") != _owner.maxDiameter) { renderer.material.SetFloat("_XLength", _owner.maxDiameter); } Supporting.Log(string.Format("Setting {0} xray opacity to 1", renderer.name), 2); }
public void PlayerLost(Vector3 position) { if (_debug) { Supporting.Log(string.Format("{0} lost the Player", gameObject.name), gameObject); } _lastKnownPlayerPosition = position; playerLost(); }
public void TakeHit(float stunTime, bool rangedAttack = false) { if (_debugAll) { Supporting.Log(string.Format("{0} was hit", gameObject.name), gameObject); } enemyHit(); _aiStunned.EnterStun(stunTime, rangedAttack); }
public void AttackOnEnter() { if (_debug || _debugAll) { Supporting.Log(string.Format("{0} is entering Attack State", gameObject.name), gameObject); } _anim.SetTrigger(AnimationParameters.Attack.ToString()); _anim.SetBool(AnimationParameters.AttackState.ToString(), true); _aiAttack.EnterAttack(); }