public override void EnterState(AIController controller) { // no pathing controller.InterruptPath(); controller.EnablePathfinding(false); enteredShootTime = Time.time; }
// Use this for initialization void Start() { control = GetComponent<AIController> (); navMeshAgent = this.GetComponent<NavMeshAgent> (); chariotObjects = GameObject.FindGameObjectsWithTag ("otherChariot"); player = GameObject.Find ("finalChar"); }
public void SetAIController() { enabled = (originalController != null && originalController.states.Count > 0); if (enabled) { triggers= new List<BaseTrigger>(); attributes= new List<BaseAttribute>(); controller=(AIController)ScriptableObject.Instantiate(originalController); for(int i=0;i<controller.parameters.Count;i++) { controller.parameters[i]=(NamedParameter)ScriptableObject.Instantiate(controller.parameters[i]); controller.parameters[i].OnChangeParameter = OnChangeParameter; } for(int i=0;i< controller.states.Count;i++) { controller.states[i]=(State)ScriptableObject.Instantiate(controller.states[i]); controller.states[i].Initialize(this); if(controller.states[i] is BaseTrigger){ triggers.Add(controller.states[i] as BaseTrigger); } if(controller.states[i] is OnAttributeChanged){ attributes.Add((controller.states[i] as OnAttributeChanged).attribute); } } currentStateIndex= controller.states.FindIndex (state => state.isDefaultState == true); anyState = (AnyState)controller.states.Find (state => state.GetType() == typeof(AnyState)); } }
public override void OnGUI (Rect position, SerializedProperty property, GUIContent label) { position.x += 4; position.width -= 4; if (!initialized) { AIEditorWindow[] windows=Resources.FindObjectsOfTypeAll<AIEditorWindow>(); if(windows.Length >0){ controller = windows[0].controller; } initialized=true; } if (controller != null) { string[] parameters=controller.GetParameterNames(typeof(GameObjectParameter)); System.Array.Resize (ref parameters, parameters.Length + 1); parameters[parameters.Length - 1] = "Owner"; List<string> list= new List<string>(parameters); list.Swap(0,parameters.Length-1); parameters=list.ToArray(); for(int i=0;i< parameters.Length;i++){ if(parameters[i] == property.stringValue){ selectedIndex=i; } } if(parameters.Length>0){ selectedIndex=EditorGUI.Popup(position,label.text,selectedIndex,parameters); } property.stringValue=parameters[selectedIndex]; } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { position.x += 4; position.width -= 6; if (!initialized) { AIEditorWindow[] windows=Resources.FindObjectsOfTypeAll<AIEditorWindow>(); if(windows.Length >0){ controller = windows[0].controller; } initialized=true; } if (controller != null) { NamedParameter param=(NamedParameter)property.objectReferenceValue; if(param == null){ property.objectReferenceValue=param=CreateUserParameter(); } position.width-=15; Rect r= new Rect(position); r.x+=position.width; r.width=20; param.userVariable=GUI.Toggle(r,param.userVariable,GUIContent.none); if(param != null && param.userVariable){ param.Name=string.Empty; SerializedObject paramObject= new SerializedObject(param); paramObject.Update(); EditorGUI.PropertyField(position,paramObject.FindProperty("value"),new GUIContent(label.text)); paramObject.ApplyModifiedProperties(); }else{ string[] parameters=null; if(fieldInfo.FieldType == typeof(Vector3Parameter)){ parameters=controller.GetParameterNames(fieldInfo.FieldType,typeof(GameObjectParameter)); }else{ parameters=controller.GetParameterNames(fieldInfo.FieldType); } if(parameters.Length == 0){ System.Array.Resize (ref parameters, parameters.Length + 1); parameters[parameters.Length - 1] = "None"; List<string> list= new List<string>(parameters); list.Swap(0,parameters.Length-1); parameters=list.ToArray(); } for(int i=0;i< parameters.Length;i++){ if(parameters[i] == param.Name){ selectedIndex=i; } } GUI.color=(parameters[selectedIndex]=="None"?Color.red:Color.white); selectedIndex=EditorGUI.Popup(position,label.text,selectedIndex,parameters); GUI.color=Color.white; if(parameters[selectedIndex]!="None"){ param.Name=parameters[selectedIndex]; } } } }
public override void Enter(AIController ai) { //Debug.Log ("Wander State"); timeElapsed_ = 0f; //Random.seed = (int)Time.time; wanderTime_ = Random.Range(wanderTimeMin_, wanderTimeMax_); Vector3 prevPos = ai.transform.position; bool validPos = false; for (int i = 0; i < 100; ++i) { float x = Random.Range (ai.transform.position.x - wanderRadius_, ai.transform.position.x + wanderRadius_); float y = ai.transform.position.y; float z = Random.Range (ai.transform.position.z - wanderRadius_, ai.transform.position.z + wanderRadius_); Vector3 randPos = new Vector3 (x, y, z); if (Vector3.Distance (ai.transform.position, ai.bonfire.position) > ai.distanceToBonfire) { validPos = true; towards_ = randPos; break; } } if (!validPos) ai.ChangeState (ai.leaveAltarState); ai.navAgent.speed = wanderSpeed_; ai.navAgent.destination = towards_; ai.navAgent.Resume (); }
public override void EnterState(AIController controller) { base.EnterState(controller); baseMoveSpeed = controller.baseMoveSpeed; controller.baseMoveSpeed = baseMoveSpeed * controller.beserkSpeedModifier; }
public override BehaviourSM.StateResponse Update(AIController controller) { ChargeBossController bossController = (ChargeBossController)controller; float elapsedStun = Time.time - startedTelegraph; Vector3 lookDirection = controller.target != null ? controller.target.transform.position - controller.transform.position : controller.transform.forward; lookDirection.Normalize(); Vector3 currentFacing = controller.headTransform.up; Vector3 newFacing = Vector3.RotateTowards(currentFacing, lookDirection, controller.baseAimRotSpeed * Time.deltaTime, 0.0f); newFacing.z = 0.0f; controller.headTransform.up = newFacing; controller.headTransform.localPosition = Random.insideUnitCircle * shakeMag; if(elapsedStun > bossController.telegraphLength) { // TODO: go to telegraph state //ChargeBossController bossController = (ChargeBossController)controller; BehaviourSM.BehaviourState nextAttack = bossController.GetNextAttackState(); return new BehaviourSM.StateResponse(BehaviourSM.TransitionMode.AbandonCurrent, nextAttack); } return new BehaviourSM.StateResponse(BehaviourSM.TransitionMode.NoChange); }
public override BehaviourSM.StateResponse Update(AIController controller) { ChargeBossController bossController = (ChargeBossController)controller; float elapsedStun = Time.time - enteredShootTime; Vector3 currentFacing = controller.headTransform.up; currentFacing = Vector3.RotateTowards(currentFacing, controller.headTransform.right, bossController.shootingSpinRate * Time.deltaTime, 0.0f); controller.headTransform.up = currentFacing; // Try it with movement towards player Vector3 toTarget = controller.target.transform.position - controller.transform.position; if(toTarget.magnitude > minDistToTarget) { controller.MoveDirect(toTarget.normalized, controller.baseMoveSpeed * chaseSpeedMult); } // decide if it should shoot a bullet if(Time.time - lastShootTime > bossController.shootingFireDelay) { bossController.FireBullet(); lastShootTime = Time.time; } if(elapsedStun > spinShootLength) { // TODO: wait state? just tracks the player for some time return new BehaviourSM.StateResponse(BehaviourSM.TransitionMode.AbandonCurrent, new Behaviour_Boss_TelegrapthCharge()); } return new BehaviourSM.StateResponse(BehaviourSM.TransitionMode.NoChange); }
public BaseAgent(AIController ai, String name) { this.ai = ai; baseConfidence = 0; modifier = 1; agentName = name; }
public override BehaviourSM.StateResponse Update(AIController controller) { Vector3 lookDirection = controller.target != null? controller.target.transform.position - controller.transform.position : controller.transform.forward; lookDirection.Normalize(); // lerp towards the current look direction Vector3 currentFacing = controller.headTransform.up; controller.headTransform.up = Vector3.RotateTowards(currentFacing, lookDirection, controller.baseAimRotSpeed * Time.deltaTime, 0.0f); if(isBursting) { controller.SetCanMove(false); } else { controller.SetCanMove(true); } // Update the current weapon if(controller.MechComponent != null && controller.MechComponent.leftWeapon != null) { controller.MechComponent.leftWeapon.UpdateAIAttackState(controller); } bool hasLos = controller.HasLOSTarget(); if(hasLos) { lastSawTargetTime = Time.time; lastKnownTargetPos = controller.target.transform.position; // move to new shooting position at random intervals if(Time.time - lastMoveTime > currentMoveInterval) { lastMoveTime = Time.time; currentMoveInterval = Random.Range(minMoveInterval, maxMoveInterval); float engagementRange = controller.GetAttackRange(); // the ideal location is some distance away from target, slightly random direction offset though Vector3 offsetDirection = (lookDirection + (Vector3)Random.insideUnitCircle).normalized; Vector3 shootingPosition = controller.target.transform.position - offsetDirection * engagementRange; controller.SetMovetoTarget(shootingPosition); } } else { // If its run out of LOS, move towards the last known position of the target if(controller.target != null) { controller.SetMovetoTarget(controller.target.transform.position); } } // Handle firing at target AttackTarget(controller); // TRANSITIONS: // give up looking for target, go to previous state if(!hasLos && Time.time - lastSawTargetTime > attentionSpan ||controller.target == null) { controller.InterruptPath(); return new BehaviourSM.StateResponse(BehaviourSM.TransitionMode.PopPrevious); } return new BehaviourSM.StateResponse(BehaviourSM.TransitionMode.NoChange); }
private long timesCalled = 0;//How much times has an agent been called /// <summary> /// Used to create an instance of the debugger with some start parameters /// </summary> /// <param name="parent"></param> /// <param name="controller"></param> /// <returns></returns> public static AIDebugSystem CreateComponent(GameObject parent, AIController controller) { AIDebugSystem AIDSys = parent.AddComponent<AIDebugSystem>(); AIDSys.controller = controller; AIDSys.enabled = true; AIDSys.debugSphere = new DebugSphere(Vector3.zero, 10); return AIDSys; }
public override void EnterState(AIController controller) { // Charge directly at player, no pathing controller.InterruptPath(); controller.EnablePathfinding(false); ((ChargeBossController)controller).BeginChargeAttack(); }
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (owner == null) owner = animator.GetComponent<AIController>(); target = GameManager.Instance.Wizard.transform; owner.agent.SetDestination(target.position); }
public override void ExitState(AIController controller) { controller.EnablePathfinding(true); ChargeBossController bossController = (ChargeBossController)controller; if(bossController.isWeakend) { bossController.CloseWeakSpot(); } }
public RetreatAgent(AIController ai, AttackAgent aA, AssistAgent assist, string name) : base(ai, name) { attackAgent = aA; enemySquadBoundingBox = new Rect(); ownSquadBoundingBox = new Rect(); assistAgent = assist; }
public BehaviourSM(AIController owner) { this.owner = owner; stateStack = new Stack<BehaviourState>(); baseState = new Behaviour_Idle(); baseState.EnterState(owner); currentState = baseState; }
public SearchState(AIController aiController) { this.aiController = aiController; playerActions = aiController.GetComponent<PlayerActions>(); pathManager = aiController.GetComponent<PathFinderManager>(); ChooseNewTarget(); lastPositionTarget = target; }
public Faction(string name, bool controlled_by_human, int ID, Color aura_colour, Color unit_tint, float ai_offense_score) { offensive_ai_score = ai_offense_score; faction_ID = ID; human_controlled = controlled_by_human; faction_name = name; faction_color = aura_colour; unit_color = unit_tint; AI = new AIController(this); }
public override BehaviourSM.StateResponse Update(AIController controller) { float elapsedStun = Time.time - enteredStunTime; if(elapsedStun > stunLength) { return new BehaviourSM.StateResponse(BehaviourSM.TransitionMode.AbandonCurrent, new Behaviour_Boss_TelegrapthCharge()); } return new BehaviourSM.StateResponse(BehaviourSM.TransitionMode.NoChange); }
public override void EnterState(AIController controller) { // no pathing controller.InterruptPath(); controller.EnablePathfinding(false); startedTelegraph = Time.time; ChargeBossController bossController = (ChargeBossController)controller; bossController.BeginTelegraphAttack(); }
void Awake () { startPos = transform.position; AIControl = GetComponent<AIController>(); if (PlayerNum == 1 && PlayerPrefs.GetString("gamemode") == "singleplayer") { PlayerIsAI = true; } touchInput = GameObject.Find ("GameHandler").GetComponent<TouchInput>(); }
public override void Start(AI ai) { base.Start(ai); control = ai.WorkingMemory.GetItem<AIController>("controller"); endPoint = ai.WorkingMemory.GetItem<Transform>("movementTarget"); if (!control.GetState().Moving) { Debug.Log("Move To: " + endPoint); control.SetMovementTarget(endPoint); } }
public static void Init (AIController controller) { editor = (AIEditorWindow)EditorWindow.GetWindow (typeof(AIEditorWindow)); editor.controller = controller; editor.title = controller.name; State state = editor.controller.states.Find (x => x.GetType() == typeof(AnyState)); if (state == null) { editor.OnCreateStateCallback(new object[]{typeof(AnyState),new Vector2(editor.position.center.x-Node.kNodeWidth*0.5f,editor.position.center.y)}); } editor.selectedState = editor.controller.states.Find (x => x.GetType() == typeof(AnyState)); }
// Use this for initialization void Start() { SP = this; Player = GameObject.FindWithTag("Player"); AI = GameObject.FindWithTag("AI"); guiText = GameObject.Find("GUI Text").GetComponent<GUIText>(); playerController = Player.GetComponent<PlayerController>(); aiController = AI.GetComponent<AIController>(); }
public ExplorerAgent(AIController ai, AssistAgent assist, String name) : base(ai, name) { ActorSelector selector = new ActorSelector() { registerCondition = gameObject => gameObject.GetComponent<FOWEntity>().IsOwnedByPlayer, fireCondition = gameObject => true }; Subscriber<FOWEntity.Actions, FOWEntity>.get.registerForAll(FOWEntity.Actions.DISCOVERED, OnEntityFound, selector); Subscriber<FOWEntity.Actions, FOWEntity>.get.registerForAll(FOWEntity.Actions.HIDDEN, OnEntityLost, selector); // Setup difficulty levels switch (ai.DifficultyLvl) { case 0: isEnabled = false; break; case 1: RescheduleSightRange = 0; ReschuduleDiceFaces = 1000; RescheduleRandomPointValue = 1000; RescheduleRandomAroundTargetValue = 990; RescheduleRandomDirectionValue = 970; MaxExplorerSquads = 1; break; case 2: RescheduleSightRange = 15; ReschuduleDiceFaces = 1000; RescheduleRandomPointValue = 1000; RescheduleRandomAroundTargetValue = 990; RescheduleRandomDirectionValue = 970; MaxExplorerSquads = 2; break; case 3: default: RescheduleSightRange = 30; ReschuduleDiceFaces = 1000; RescheduleRandomPointValue = 1000; RescheduleRandomAroundTargetValue = 990; RescheduleRandomDirectionValue = 970; MaxExplorerSquads = 2; break; } heroVisible = false; terrain = Terrain.activeTerrain; fowManager = FOWManager.Instance; heroLastPos = Vector3.zero; assistAgent = assist; }
public override BehaviourSM.StateResponse Update(AIController controller) { ChargeBossController bossController = (ChargeBossController)controller; Vector3 lookDirection = controller.target != null ? controller.target.transform.position - controller.transform.position : controller.transform.forward; lookDirection.z = 0.0f; lookDirection.Normalize(); Vector3 currentFacing = controller.headTransform.up; float turnRateMultiplier = (controller.target.transform.position - controller.transform.position).magnitude / bossController.chargeTurnRateFalloffDist; turnRateMultiplier = Mathf.Min(turnRateMultiplier, 1.0f); Vector3 chargeDirection = Vector3.RotateTowards(currentFacing, lookDirection, bossController.chargeTurnRate * Time.deltaTime * turnRateMultiplier, 0.0f); chargeDirection.z = 0.0f; controller.headTransform.up = chargeDirection; // Move direct so that it doesnt path controller.MoveDirect(chargeDirection, controller.baseMoveSpeed * bossController.chargeSpeedModifier); Vector3 toTarget = controller.target.transform.position - controller.transform.position; if(toTarget.magnitude < damageRadius) { // Damage the player, go to the stunned state, knock back the player controller.target.MovementComponent.ApplyForce(toTarget * bossController.chargeKnockbackForce); controller.target.MechComponent.TakeDamage(bossController.chargeHitDamage, controller, null); // A bit of a hack, but do a camera shake CameraController camera = GameObject.FindObjectOfType<CameraController>(); if(camera != null) { CameraController.CameraShake shakeData = new CameraController.CameraShake(0.2f, 1.0f, 1.0f, 1.0f, false); camera.StartCameraShake(ref shakeData, Vector3.up); } return new BehaviourSM.StateResponse(BehaviourSM.TransitionMode.AbandonCurrent, new Behaviour_Boss_Stunned()); } // if it collided this frame, that means it hit a wall and should go into stun state if(controller.MovementComponent.collidedThisFrame) { bossController.OpenWeakSpot(); // Again, do a smaller shake when the boss hits a wall CameraController camera = GameObject.FindObjectOfType<CameraController>(); if(camera != null) { CameraController.CameraShake shakeData = new CameraController.CameraShake(0.3f, 0.3f, 5.0f, 1.0f, false); camera.StartCameraShake(ref shakeData, Vector3.up); } return new BehaviourSM.StateResponse(BehaviourSM.TransitionMode.AbandonCurrent, new Behaviour_Boss_Stunned()); } return new BehaviourSM.StateResponse(BehaviourSM.TransitionMode.NoChange); }
/// <summary> /// Update the FuzzySets from the Global cache /// </summary> public void GetSets() { Type oldSets = null; if(_sets != null) oldSets = _sets.GetType(); //Scope out what sets are coming in... _sets = Globals.Controller; //Update the Sets from Global cache if(_sets != null) //Incase there have been no sets defined for the Simulator... if(_sets.GetType() != oldSets) //Check for Simulator Type Change DrawSets(); //If they're new, draw 'em }
public override BehaviourSM.StateResponse Update(AIController controller) { Vector3 targetLoc = controller.target.transform.position; bool hasLos = controller.HasLOSTarget(); if(hasLos) { controller.SetMovetoTarget(targetLoc); } // In range to explode if((targetLoc - controller.transform.position).magnitude < suicideRadius) { controller.CommitSuicide(); } return new BehaviourSM.StateResponse(BehaviourSM.TransitionMode.NoChange); }
public AttackAgent(AIController ai, AssistAgent assist, string name) : base(ai, name) { if (ai.race == Storage.Races.ELVES) { _maxUnitRange = Storage.Info.get.of(Storage.Races.MEN, Storage.UnitTypes.THROWN).unitAttributes.rangedAttackFurthest; _enemyRace = Storage.Races.MEN; } else { _maxUnitRange = Storage.Info.get.of(Storage.Races.ELVES, Storage.UnitTypes.THROWN).unitAttributes.rangedAttackFurthest; _enemyRace = Storage.Races.ELVES; } assistAgent = assist; }
void Awake() { aiController = gameObject.GetComponentInChildren <AIController>() as AIController; //FillWaypointList(); }
public void OnTriggerStay(Collider other) { if (other.gameObject.tag == ("PickUp") && hasItem == false) { aButton.gameObject.SetActive(true); if (Input.GetButton("XboxA") && hasItem == false) { aButton.gameObject.SetActive(false); hasItem = true; pickup = other.gameObject.GetComponent <Item>(); pickup.circle.SetActive(false); pickup.pickedUp = true; pickup.transform.parent = transform; pickup.transform.position = ItemPos.position; pickup.transform.rotation = ItemPos.rotation; Debug.Log("pick up"); Debug.Log(pickup.name); } } if (other.gameObject.tag == "AI") { if (hasItem == true) { ai = other.GetComponent <AIController>(); if (ai.state == AIController.States.Want) { aButton.gameObject.SetActive(true); } if (ai.state == AIController.States.Crying && currentSweets != 0) { yButton.gameObject.SetActive(true); } } if (Input.GetButtonDown("XboxA") && hasItem) { ai = other.GetComponent <AIController>(); if (ai.state == AIController.States.Want) { aButton.gameObject.SetActive(false); bool correct = ai.ReceiveItem(pickup); if (correct) { //Debug.Log("SweetTest"); hasItem = false; currentSweets++; Image icon = Instantiate(sweetIcon, FindObjectOfType <CanvasScaler>().gameObject.transform); icon.GetComponent <ButtonPos>().buttonPos = butPos; Destroy(icon, 3); } } } ai = other.GetComponent <AIController>(); if (ai.state == AIController.States.Crying && currentSweets != 0) { yButton.gameObject.SetActive(true); } if (Input.GetButton("XboxY")) { ai = other.GetComponent <AIController>(); if (ai.state == AIController.States.Crying && currentSweets != 0) { yButton.gameObject.SetActive(false); ai.ReceiveSweet(); currentSweets--; } } } }
public abstract void Execute(AIController aI);
public override bool Decide(AIController controller) { return(controller.IsGrounded); }
private void Start() { aicontroller = GetComponent <AIController>(); }
/// <summary>Define the overrideable Decide method to return if coffee is in range to drink or not. /// <param> AIController controller /// </summary public override bool Decide(AIController controller) { return(controller.coffeeInRange); }
public KingDuelBehaviour(AIController aAIController) : base(aAIController) { m_AIController = aAIController; KingDuelAttackTimer = Services.TimerManager.CreateTimer("KingDuelAttackTimer", 1.0f, false); }
// Use this for initialization void Start() { System.Diagnostics.Debug.WriteLine("Starting Game..."); // Randomly pick positions for the player and AI to start at Transform[] topAlcoves = { topAlcove1, topAlcove2, topAlcove3, topAlcove4, topAlcove5 }; Transform[] bottomAlcoves = { bottomAlcove1, bottomAlcove2, bottomAlcove3, bottomAlcove4, bottomAlcove5 }; // Initialize items in each alcove itemsRemaining = new List <Transform>(); for (int i = 0; i < 5; i++) { itemsRemaining.Add(Instantiate(item, bottomAlcoves[i].position, Quaternion.identity).transform); } for (int i = 0; i < 5; i++) { itemsRemaining.Add(Instantiate(item, topAlcoves[i].position, Quaternion.identity).transform); } int playerAlcove = Random.Range(0, 5); player = Instantiate(playerPrefab, topAlcoves[playerAlcove].position, Quaternion.identity).GetComponent <PlayerController>(); player.game = this; int aiAlcove = Random.Range(0, 5); ai = Instantiate(aiAgent, bottomAlcoves[aiAlcove].position, Quaternion.identity).GetComponent <AIController>(); ai.game = this; ai.target = bottomAlcoves[aiAlcove]; // Initate two enemies, one on the top and one on the bottom. Randomly decide which door each one starts at. topEnemies = new EnemyController[numOfEnemies]; bottomEnemies = new EnemyController[numOfEnemies]; for (int i = 0; i < numOfEnemies; i++) { int doorDecision = Random.Range(0, 2); // Pick a number 0 or 1 if (doorDecision == 0) { // The top enemy starts at the left door topEnemies[i] = Instantiate(enemy, topLeftDoor.GetChild(0).position, Quaternion.identity).GetComponent <EnemyController>(); topEnemies[i].source = topLeftDoor; topEnemies[i].target = topRightDoor; topEnemies[i].visionField = Instantiate(visionFieldPrefab, new Vector3(-17, 1, 5.4f), Quaternion.identity); topEnemies[i].visionOffset = 1; topEnemies[i].visionZPosition = 5.4f; topEnemies[i].visionFieldPrefab = visionFieldPrefab; } else { // The top enemy starts at the right door topEnemies[i] = Instantiate(enemy, topRightDoor.GetChild(0).position, Quaternion.identity).GetComponent <EnemyController>(); topEnemies[i].source = topRightDoor; topEnemies[i].target = topLeftDoor; topEnemies[i].visionField = Instantiate(visionFieldPrefab, new Vector3(17, 1, 5.4f), Quaternion.identity); topEnemies[i].visionOffset = -1; topEnemies[i].visionZPosition = 5.4f; topEnemies[i].visionFieldPrefab = visionFieldPrefab; } doorDecision = Random.Range(0, 2); // Pick a number 0 or 1 if (doorDecision == 0) { // The bottom enemy starts at the left door bottomEnemies[i] = Instantiate(enemy, bottomLeftDoor.GetChild(0).position, Quaternion.identity).GetComponent <EnemyController>(); bottomEnemies[i].source = bottomLeftDoor; bottomEnemies[i].target = bottomRightDoor; bottomEnemies[i].visionField = Instantiate(visionFieldPrefab, new Vector3(-17, 1, -5.4f), Quaternion.identity); bottomEnemies[i].visionOffset = 1; bottomEnemies[i].visionZPosition = -5.4f; bottomEnemies[i].visionFieldPrefab = visionFieldPrefab; } else { // The bottom enemy starts at the right door bottomEnemies[i] = Instantiate(enemy, bottomRightDoor.GetChild(0).position, Quaternion.identity).GetComponent <EnemyController>(); bottomEnemies[i].source = bottomRightDoor; bottomEnemies[i].target = bottomLeftDoor; bottomEnemies[i].visionField = Instantiate(visionFieldPrefab, new Vector3(17, 1, -5.4f), Quaternion.identity); bottomEnemies[i].visionOffset = -1; bottomEnemies[i].visionZPosition = -5.4f; bottomEnemies[i].visionFieldPrefab = visionFieldPrefab; } } playerTeleportsText.text = "Teleports: " + playerTeleportsRemaining; aiTeleportsText.text = "Teleports: " + aiTeleportsRemaining; }
public abstract void Perform(AIController controller);
/// <summary> /// Load the given controller and create all necessary objects. /// </summary> void LoadControllerInternal(AIController newController, AIBehaviour newAIBehaviour = null, bool forceLoad = false) { if (!forceLoad) { if (controller == newController && aiBehaviour == newAIBehaviour) { return; } } controller = newController; aiBehaviour = newAIBehaviour; if (newController != null) { m_exposedParameterList = new ParameterList <ExposedParameter> (GetExposedParameters, m_canvas, Repaint); m_exposedParameterList.onParameterAddClicked += CreateExposedParameter; m_exposedParameterList.onParameterRemovedClicked += RemoveExposedParameter; m_exposedParameterList.onChangeParameterIndex += ChangeExposedParameterIndex; m_exposedParameterList.onChangeParameterName += ChangeExposedParameterName; m_nodeParameterList = new ParameterList <NodeParameter> (GetNodeParameters, m_canvas, Repaint); m_nodeParameterList.onParameterAddClicked += CreateNodeParameter; m_nodeParameterList.onParameterRemovedClicked += RemoveNodeParameter; m_nodeParameterList.onChangeParameterIndex += ChangeNodeParameterIndex; m_nodeParameterList.onChangeParameterName += ChangeNodeParameterName; if (controller.isCopy) { ShowNotification(new GUIContent("AIController changes will not be saved")); } #if GRAPH_DEBUG Debug.Log("[AI Graph]: Controller loaded (" + controller.name + ") AIBehaviour (" + aiBehaviour + ")"); #endif } else { aiBehaviour = null; controller = null; m_exposedParameterList = null; m_nodeParameterList = null; #if GRAPH_DEBUG Debug.Log("[AI Graph]: Controller loaded (null) AIBehaviour (null)"); #endif } onControllerChanged?.Invoke(newController, newAIBehaviour); GraphMode oldGraphMode = m_graphMode; if (controller == null) { m_graphMode = GraphMode.NoController; } else if (controller.isCopy) { if (aiBehaviour == null) { m_graphMode = GraphMode.RuntimeController; } else { m_graphMode = GraphMode.RuntimeControllerAndAiBehaviour; } } else { if (aiBehaviour == null) { m_graphMode = GraphMode.AssetController; } else { m_graphMode = GraphMode.AssetControllerAndAiBehaviour; } } if (m_graphMode != oldGraphMode) { onGraphModeChanged?.Invoke(m_graphMode); } }
void Awake() { controller = GetComponent <Controller2D>(); AI = GetComponent <AIController>(); anim = GetComponent <Animator>(); }
public override bool Decide(AIController aI) { return(EnemySighted(aI)); }
public PatrolState(AIController controlled) : base(controlled) { }
public override bool Decide(AIController aI) { return(TargetOnSight(aI)); }
public virtual void SetControlledAI(AIController newControlledAI) { ControlledAI = newControlledAI; }
public ShootState(AIController owner) : base(owner) { this.owner = owner; StateColor = Color.red; }
// Use this for initialization void Start() { controller = Body.GetComponent <AIController>(); }
private void Start() { creatmonster(20, 5, 2); ai_c = gameObject.GetComponent <AIController>(); }
void FinishLevelSetup(GameObject p1, GameObject p2) { var placeholder1 = Players.transform.GetChild(0); Players.transform.GetChild(0).SetParent(null); placeholder1.SetParent(p1.transform); var placeholder2 = Players.transform.GetChild(0); Players.transform.GetChild(0).SetParent(null); placeholder2.SetParent(p2.transform); Destroy(Players); Health.SetActive(true); Specialbars[0].SetActive(true); //Specialbars[1].GetComponent<SpecialBar>().ResetLevel(); //Specialbars[2].GetComponent<SpecialBar>().ResetLevel(); RoundsParent.SetActive(true); Rounds[0].GetComponent <RoundUpdater>().ResetRounds(); Rounds[1].GetComponent <RoundUpdater>().ResetRounds(); //var playerbases = p1.GetComponents<PlayerBase>(); PlayerBase p1Script = p1.GetComponent <PlayerBase>(); PlayerBase p2Script = p2.GetComponent <PlayerBase>(); //playerbases[1].healthBar = bar1; p1Script.healthBar = bar1; p2Script.healthBar = bar2; p1Script.specialBar = Specialbars[1].GetComponent <SpecialBar>(); p2Script.specialBar = Specialbars[2].GetComponent <SpecialBar>(); //bar1.SetUp(playerbases[1]); bar1.SetUp(p1Script); bar2.SetUp(p2Script); //print("Hello Sir"); if (gameType == GameType.CPUMODE) { AIController ai1 = p1.AddComponent <AIController>(); AIController ai2 = p2.AddComponent <AIController>(); ai1.player = p1Script; ai1.opponent = p2Script; ai1.player.isAI = true; ai2.player = p2Script; ai2.opponent = p1Script; ai2.player.isAI = true; } else if (gameType == GameType.ONEPLAYER) { AIController ai2 = p2.AddComponent <AIController>(); ai2.player = p2Script; ai2.opponent = p1Script; ai2.player.isAI = true; } else if (gameType == GameType.TRAINING) { p1Script.isTraining = true; p2Script.isTraining = true; } ResetPlayers(1f); }
public override void PrepareAction(AIController controller) { }
public MovingState(AIController aiController) : base(aiController) { }
void Start() { aiController = GetComponent <AIController>(); }
public State(AIController owner) { this.owner = owner; ownerTransform = owner.transform; }
IEnumerator InitCoroutine() { InitPlayMode(); //gamePlayMode.gameMode = GameMode.VSAI; UIInstance = Instantiate(uiPrefab); UIInstance.Init(gamePlayMode.boardSideLength, prefabConfig); boardInstance = Instantiate(boardInstancePrefab); boardManager = GetComponent <BoardManager>(); boardManager.Init(gamePlayMode); while (!boardManager.IsReady()) { yield return(0); } switch (gamePlayMode.gameMode) { case GameMode.OneClientTwoPlayers: controller = Instantiate(controllerPrefab); controller.name = "Player 1"; controller2 = Instantiate(controllerPrefab); controller2.name = "Player 2"; controller.Init(gamePlayMode.boardSideLength, UIInstance.panels); controller2.Init(gamePlayMode.boardSideLength, UIInstance.panels); break; case GameMode.VSAI: controller = Instantiate(controllerPrefab); controller.name = "Player 1"; controller2 = Instantiate(controllerPrefab); controller2.name = "AI"; controller.Init(gamePlayMode.boardSideLength, UIInstance.panels); controller2.Init(gamePlayMode.boardSideLength, UIInstance.panels); break; case GameMode.Teaching: controller = Instantiate(controllerPrefab); controller.name = "Player 1"; controller2 = Instantiate(controllerPrefab); controller2.name = "AI"; controller.Init(gamePlayMode.boardSideLength, UIInstance.panels); controller2.Init(gamePlayMode.boardSideLength, UIInstance.panels); break; default: break; } boardInstance.Init(prefabConfig); GameStart(); if (gamePlayMode.gameMode == GameMode.OneClientTwoPlayers) { currentController = controller; controller.gameObject.SetActive(true); controller2.gameObject.SetActive(false); } else if (gamePlayMode.gameMode == GameMode.VSAI) { currentController = controller; controller.gameObject.SetActive(true); controller2.gameObject.SetActive(false); aiController = gameObject.AddComponent <AIController>(); } UnityAction BoardDisappear = new UnityAction(boardInstance.BoardDisappear); UnityAction UIDisappear = new UnityAction(UIInstance.ActionsOnGameEnd); UIAndBoardLogic_WhenGameEnd.AddListener(BoardDisappear); UIAndBoardLogic_WhenGameEnd.AddListener(UIDisappear); }
public void GetAIController() { aIController = GetComponent <AIController>(); }
public KingLunge(AIController aAIController) : base(aAIController) { m_KingLungeTimer = Services.TimerManager.CreateTimer("m_KingLungeTimer", LungeDuration, false); m_KingLungeDelayTimer = Services.TimerManager.CreateTimer("m_KingLungeDelayTimer", LungeDelay, false); }
public AttackToPatrolCondition(AIController aiController) : base(aiController) { }
public override void EnterState(AIController AI) { Debug.Log("Medium State Activate!"); DifType = AIDifficultyType.Medium; }
public override void Execute(AIController aiCtr) { aiCtr.Enemy.SetInputs(aiCtr.TargetDirection(targetOffset)); }
public abstract void OnStateEnter(AIController aI);