void Awake() { if (AllPlayers == null) { AllPlayers = new List <PlayerController>(); } playerID = GetComponent <PlayerInput>().playerIndex; AllPlayers.Insert(playerID, this); AIDirector.SetInCombat(this, false); cc = GetComponent <CharacterController>(); ammoStash = new Dictionary <Weapon.AmmoType, int>(); bool uh = false; //Needed a bool for some reason playerInput = GetComponent <PlayerInput>(); //playerInput.actions.FindAction("Shoot", uh).performed += ctx => shootInput = true; //playerInput.actions.FindAction("Shoot", uh).canceled += ctx => shootInput = false; playerInput.actions.FindAction("Shoot", uh).performed += ctx => ToggleShooting(true); playerInput.actions.FindAction("Shoot", uh).canceled += ctx => ToggleShooting(false); playerInput.actions.FindAction("Sprint", uh).performed += ctx => ToggleRun(true); playerInput.actions.FindAction("Sprint", uh).canceled += ctx => ToggleRun(false); playerInput.actions.FindAction("Crouch", uh).performed += ctx => ToggleCrouch(true); playerInput.actions.FindAction("Crouch", uh).canceled += ctx => ToggleCrouch(false); SetCullingMasks(); SetUpUI(); OnPause();//KÄND BUG - Måste börja med UI-actionmappen }
private void Start() { aIDirector = GameObject.FindGameObjectWithTag("AIDirector").GetComponent <AIDirector>(); texts = new List <Text>(transform.GetComponentsInChildren <Text>()); isTurnedOn = true; }
void Start() { S_Adire = GetComponent <AIDirector>(); // ディレクタスクリプト取得 Pdata = S_Adire.GetPData; bullets[0].transform.parent.transform.parent = null; // 弾丸がプレイヤに合わせて動かないようにする Invoke(nameof(SetTeam), 0.5f); }
void Awake() { // 自身のスクリプトを取得 S_Adire = GetComponent <AIDirector>(); m_team = GetComponent <TeamScript>(); RegisterEvent_ChangeHaveFlag(SetHaveFlag); }
void Start() { S_Adire = GetComponent <AIDirector>(); // ディレクタ取得 Pdata = S_Adire.GetPData; RespawnPos = transform.position; // リスポーン地点取得 audio = GetComponent <AudioSource>(); Invoke(nameof(SetTeam), 0.5f); }
private void Awake() { if (Instance == null) { Instance = this; } PlayerCombatInfo = new Dictionary <PlayerController, CombatInfo>(); }
void Start() { S_Adire = GetComponent <AIDirector>(); // ディレクター取得 S_Amove = GetComponent <AIMove>(); // 移動スクリプト取得 S_Agun = GetComponent <AIGun>(); // 射撃スクリプト取得 S_Alife = GetComponent <AILife>(); // ライフスクリプト取得 RegisterObj(); // 変身するオブジェクトをリストに格納 SetOdata(OdataList[mynum]); }
// Start is called before the first frame update private void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } }
protected virtual void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); } }
void Awake() { navMeshAgent = GetComponent <NavMeshAgent> (); animator = GetComponentInChildren <Animator>(); moveCommandLocation = Vector3.zero; directorReference = FindObjectOfType <AIDirector>(); aiActive = true; }
// Use this for initialization void Start() { if (instance != null) { Destroy (gameObject); } else { instance = this; GameObject.DontDestroyOnLoad(gameObject); } startTime = Time.time; aid = GameObject.FindObjectOfType<AIDirector>(); }
// Use this for initialization void Start() { director = FindObjectOfType <AIDirector>(); nav = GetComponent <UnityEngine.AI.NavMeshAgent>(); nav.enabled = true; anim = GetComponentInChildren <Animator>(); pushableLayer = LayerMask.GetMask("Pushable"); pushing = false; pushCounter = 0; pushingTimer = 0; }
// 移動中に敵を追いかけているときの処理 bool FightEnemy() { if (m_fightingEnemyPDirector != null) { // プレイヤが死んでいるか確認する if (m_fightingEnemyPDirector.PState == 2 || m_fightingEnemyPDirector.PState == 3) { m_nowEnemyLostTime = 0f; FindEnemyFlag = false; m_fightingEnemy = null; m_fightingEnemyPDirector = null; m_fightingEnemyAIDirector = null; return(false); } } else { // プレイヤが死んでいるか確認する if (m_fightingEnemyAIDirector.NowState == AIState.DEAD || m_fightingEnemyAIDirector.NowState == AIState.RESPAWN) { m_nowEnemyLostTime = 0f; FindEnemyFlag = false; m_fightingEnemy = null; m_fightingEnemyPDirector = null; m_fightingEnemyAIDirector = null; return(false); } } if (!CheckLostEnemy(m_fightingEnemy.position)) // 敵を見失っていないか { m_nowEnemyLostTime += Time.deltaTime; if (m_nowEnemyLostTime > m_enemyLostTime) // 一定秒数以上見失っているか { m_nowEnemyLostTime = 0f; FindEnemyFlag = false; m_fightingEnemy = null; m_fightingEnemyPDirector = null; m_fightingEnemyAIDirector = null; return(false); } return(true); } else { m_nowEnemyLostTime = 0f; return(true); } }
// 敵が見えているか bool CheckFindEnemy() { for (int i = 0; i < m_enemyT.Count; ++i) { // AIからプレイヤまでのベクトル Vector3 vec = m_enemyT[i].position - MyObject.position; // プレイヤまでの距離が一定以内だったら if (visibleRange * visibleRange >= vec.sqrMagnitude) { vec.y = 0; // AIの視界内にプレイヤがいるかどうか if (Vector3.Angle(MyObject.forward, vec) <= visibleAngle) { // プレイヤと自身の間に障害物があるか調べる if (Physics.Linecast(MyObject.position + Odata.BulletOffset, m_enemyT[i].position + new Vector3(0, 1f, 0), layermask.value)) { continue; } m_fightingEnemy = m_enemyT[i]; if (m_fightingEnemy.GetComponent <PlayerDirector>()) { m_fightingEnemyPDirector = m_fightingEnemy.GetComponent <PlayerDirector>(); m_fightingEnemyAIDirector = null; if (m_fightingEnemyPDirector.PState == 2 || m_fightingEnemyPDirector.PState == 3) { m_fightingEnemy = null; m_fightingEnemyPDirector = null; continue; } } else if (m_fightingEnemy.GetComponent <AIDirector>()) { m_fightingEnemyAIDirector = m_fightingEnemy.GetComponent <AIDirector>(); m_fightingEnemyPDirector = null; if (m_fightingEnemyAIDirector.NowState == AIState.DEAD || m_fightingEnemyAIDirector.NowState == AIState.RESPAWN) { m_fightingEnemy = null; m_fightingEnemyAIDirector = null; continue; } } FindEnemyFlag = true; return(true); } } } return(false); }
public override void OnNotify(string p_event, params object[] p_objects) { base.OnNotify(p_event, p_objects); switch (p_event) { case EventFlag.Game.SetUp: { Debug.Log("Game Start"); _mapGeneration = MainApp.Instance.FindObject <MapGenerator>("model/map_generator"); _themeGeneration = MainApp.Instance.FindObject <ThemeGenerator>("model/map_generator"); _inputController = MainApp.Instance.GetObserver <InputController>(); _aiDirector = MainApp.Instance.GetObserver <AIDirector>(); _camera = MainApp.Instance.FindObject <CameraHandler>("view/camera"); Init(); } break; case EventFlag.Game.PlayerMove: { CA_Terrain.TerrainBuilder terrainBuilder = _mapGeneration.AssignSRandomTerrain(); _aiDirector.AssignAgentsInSingleRow(terrainBuilder); }; break; case EventFlag.Game.UnitAttack: { if (p_objects.Length == 2) { OnUnitAttack((BaseUnit)p_objects[0], (BaseUnit)p_objects[1]); } }; break; case EventFlag.Game.UnitDestroy: { OnUnitDestroy((BaseUnit)p_objects[0]); } break; } }
void Awake() { S_Adire = GetComponent <AIDirector>(); rb = GetComponent <Rigidbody>(); // rigidbodyを取得 }
// Use this for initialization void Start() { director = transform.parent.GetComponent<AIDirector>(); if (director == null) { Debug.LogError("AI Director reference not found."); } body = gameObject.GetComponent("Rigidbody") as Rigidbody; if (body == null) { Debug.LogError("Rigidbody reference not found."); } if (debug) { debugAreaSphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); Material material = new Material (Shader.Find("Transparent/Diffuse")); SphereCollider sphereCollider = debugAreaSphere.GetComponent<SphereCollider>(); sphereCollider.isTrigger = true; debugAreaSphere.renderer.material = material; debugAreaSphere.transform.parent = transform; debugAreaSphere.transform.position = transform.position; debugAreaSphere.transform.localScale = new Vector3(aggroArea*2, aggroArea*2, aggroArea*2); } changeStateTo(State.Idle); director.registerNewEnemy(gameObject, this); }
// Use this for initialization void Start() { ai = GameObject.FindObjectOfType<AIDirector>() as AIDirector; origin = transform.position; myself = gameObject; if (range > sight) range = sight; }
private void Awake() { directorReference = FindObjectOfType <AIDirector>(); // Find and set director reference }
private GameManager() { AiDirector = new AIDirector(); _mListOfPlayers = new List <PlayerCTRL>(); }
public void Aggro(PlayerController player) { animator.SetBool("Aggressive", true); AIDirector.SetInCombat(player, true); }
private void Awake() { _instance = this; }
//should only be used once on object creation to link to AI director - perhaps move to another class? public void setDirector(AIDirector newDirector) { director = newDirector; }