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 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(); } }
/// <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)); } }
public void IdleOnUpdate() { if (_debugAll) { Supporting.Log(string.Format("{0} is in Idle State", gameObject.name), gameObject); } _aiIdle.UpdateIdle(); }
// [THISSHIT] [TH] - QUESTION - WTF? public void FinishRecover() { if (_debugAll) { Supporting.Log(string.Format("{0} finished recovered", gameObject.name), gameObject); } idle(); }
public void PatrolOnUpdate() { if (_debugAll) { Supporting.Log(string.Format("{0} is in Patrol State", gameObject.name), gameObject); } _aiPatrol.UpdatePatrol(); }
public void StunnedOnUpdate() { if (_debugAll) { Supporting.Log(string.Format("{0} is in Stunned State", gameObject.name), gameObject); } _aiStunned.UpdateStun(); }
public void SearchOnExit() { if (_debug || _debugAll) { Supporting.Log(string.Format("{0} is exiting Search State", gameObject.name), gameObject); } _aiSearch.ExitSearch(); }
public void ChaseOnExit() { if (_debug || _debugAll) { Supporting.Log(string.Format("{0} is exiting Chase State", gameObject.name), gameObject); } _aiChase.ExitChase(); }
public void AttackOnUpdate() { if (_debugAll) { Supporting.Log(string.Format("{0} is in Attack State", gameObject.name), gameObject); } _aiAttack.UpdateAttack(); }
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 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 Recover() { if (_debugAll) { Supporting.Log(string.Format("{0} recovered", gameObject.name), gameObject); } recover(); }
public void ChaseOnUpdate() { if (_debugAll) { Supporting.Log(string.Format("{0} is in Chase State", gameObject.name), gameObject); } _aiChase.UpdateChase(); }
public void PatrolOnExit() { if (_debug || _debugAll) { Supporting.Log(string.Format("{0} is exiting Patrol State", gameObject.name), gameObject); } _aiPatrol.ExitPatrol(); }
public void SearchOnUpdate() { if (_debugAll) { Supporting.Log(string.Format("{0} is in Search State", gameObject.name), gameObject); } _aiSearch.UpdateSearch(); }
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(); }
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 PatrolOnEnter() { if (_debug || _debugAll) { Supporting.Log(string.Format("{0} is entering Patrol State", gameObject.name), gameObject); } _anim.SetTrigger(AnimationParameters.Patrol.ToString()); _aiPatrol.EnterPatrol(); }
public void IdleOnEnter() { if (_debug || _debugAll) { Supporting.Log(string.Format("{0} is entering Idle State", gameObject.name), gameObject); } _anim.SetTrigger(AnimationParameters.Idle.ToString()); _anim.SetBool(AnimationParameters.IdleState.ToString(), true); _aiIdle.EnterIdle(); }
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(); }
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 PlayerLost(Vector3 position) { if (_debug) { Supporting.Log(string.Format("{0} lost the Player", gameObject.name), gameObject); } _lastKnownPlayerPosition = position; playerLost(); }
public void SetMusicVolume(float volume) { if (_masterMixer) { // Supporting.Log("Adjusting music volume to " + volume); _masterMixer.SetFloat(Persistency.MUSIC_VOLUME_KEY, volume); } else { Supporting.Log("Master Mixer not found", 2); } }
public void ChaseOnEnter() { if (_debug || _debugAll) { Supporting.Log(string.Format("{0} is entering Chase State", gameObject.name), gameObject); } _anim.SetTrigger(AnimationParameters.Chase.ToString()); _aiChase.EnterChase(); _aiFOV.On(); }
IEnumerator FindTargetsWithDelay(float delay) { while (true) { yield return(new WaitForSeconds(delay)); if (_enemy.debug) { Supporting.Log(string.Format("Scanning for Targets", _enemy.name)); } FindVisibleTargets(_standingViewRadius); } }
public void StunnedOnExit() { if (_debug || _debugAll) { Supporting.Log(string.Format("{0} is exiting Stunned State", gameObject.name), gameObject); } _anim.SetBool(AnimationParameters.StunnedState.ToString(), false); _aiStunned.ExitStun(); _capsuleCollider.center = _capsuleRegCenter; _capsuleCollider.direction = _capsuleDirection[1]; // play recover dialogue if (EnemyManager.instance.GetPermissionToSpeak()) { SoundManager.instance.PlayGuardDialogue(_dialogueSource, SoundManager.DialogueType.Recovering, _voiceNum, ref SoundManager.instance.guardRecoverDialogueArrayIndex, true); } }
public void StunnedOnEnter() { if (_debug || _debugAll) { Supporting.Log(string.Format("{0} is entering Stunned State", gameObject.name), gameObject); } _anim.SetTrigger(AnimationParameters.Stunned.ToString()); _anim.SetBool(AnimationParameters.StunnedState.ToString(), true); _aiFOV.Off(); _capsuleCollider.center = _capsuleStunnedCenter; _capsuleCollider.direction = _capsuleDirection[0]; // play stunned dialogue if (EnemyManager.instance.GetPermissionToSpeak()) { SoundManager.instance.PlayGuardDialogue(_dialogueSource, SoundManager.DialogueType.Stunned, _voiceNum, ref SoundManager.instance.guardStunnedDialogueArrayIndex, true); } }
public void SearchOnEnter() { if (_debug || _debugAll) { Supporting.Log(string.Format("{0} is entering Search State", gameObject.name), gameObject); } _anim.SetTrigger(AnimationParameters.Search.ToString()); // TODO Remove this functionality from search state // play search Dialogue if (EnemyManager.instance.GetPermissionToSpeak()) { SoundManager.instance.PlayGuardDialogue(_dialogueSource, SoundManager.DialogueType.Alerted, _voiceNum, ref SoundManager.instance.guardAlertedDialogueArrayIndex, false); } _aiSearch.EnterSearch(_aiFOV.seenPlayer); startedSearching(); _aiFOV.On(); }