public CollectHarvestBasketAction(AIAgent agent, List<IResource> resources) : base(agent) { _resources = resources; BaseUtility = 5; Name = "Collecting harves basket"; }
public GoToStorageAction(AIAgent agent, Storage storage) : base(agent) { BaseUtility = 5; Name = "Go to Starage"; _storage = storage; }
public GoToCampfireAction(AIAgent agent) : base(agent) { BaseUtility = 1; Name = "Go to Campfire"; _campFire = SettlementManager.Instance.CampFire; }
public PickupItemAction(AIAgent agent, PickableItem item) : base(agent) { Name = "PickupItem"; BaseUtility = 9; _item = item; }
public HarvestAction(AIAgent agent, IHarvestable harvestable) : base(agent) { Name = "Harvesting"; _harvestable = harvestable; BaseUtility = 5; }
public TakeItemFromStorageAction(AIAgent agent, ItemType type) : base(agent) { Name = "Pickup Item from storage"; BaseUtility = 5; _type = type; }
public GetWoodAction(AIAgent agent, Tree tree ) : base(agent) { Name = "Get Wood"; BaseUtility = 10; _tree = tree; }
public PutDownItemToStorageAction(AIAgent agent, Storage place) : base(agent) { _storage = place; Name = "Putdown item"; BaseUtility = 10; _backpack = _agent.Character.BackPack; }
public override void OnOpen(object param) { base.OnOpen(param); if (!(param is AIAgent)) { return; } ClearWindow(); m_AIAgent = param as AIAgent; var m_TreeParser = new AIDebugerTreeParser(); m_TreeRoot = m_TreeParser.CreateBehaviourTree(m_AIAgent.GetID(), m_NodeTemplate, m_TreeRootObj, ConfigManager.Instance.GetAIConfigTable()); InitTree(); m_TreeRoot.Render(0); m_AIAgent.SetDebugMode(true); UITickTask.Instance.RegisterToUpdateList(Update); }
public void Initialize(int id) { m_iId = id; m_NpcBaseInfo = ConfigManager.Instance.GetNpcConfig(id); if (null == m_NpcBaseInfo) { Debuger.LogWarning("can't load target npc: " + id); return; } m_bInitGroup = m_NpcBaseInfo.IsInGroup; m_StateMachine = new StateMachine(0, 0, this); m_CharTransformData = new CharTransformData(); m_CharTransformData.Initialize(this, m_NpcBaseInfo.ModelResource, AssetType.Char); //m_CharTransformData.AddNavmeshObs(); m_AIAgent = new AIAgent(m_NpcBaseInfo.AiId); LifeTickTask.Instance.RegisterToUpdateList(Update); MessageDispatcher.Instance.RegistMessage(ClientCustomMessageDefine.C_HIT_TERRAIN, OnHitTerrain); MessageDispatcher.Instance.RegistMessage(ClientCustomMessageDefine.C_HIT_LIFE, OnHitLife); LifeManager.RegisterLife(m_iId, this); }
public void UpdatePanel(AIAgent agent, Sprite sprite) { this.agent = agent; image.sprite = sprite; }
protected override BehaviourNodeStatus OnExecute(AIAgent agent) { return(BehaviourNodeStatus.Failure); }
public virtual void Init(AIAgent owner) { _stateOwner = owner; _inState = false; }
void AIState.Enter(AIAgent agent) { }
protected override void AgentEndInteraction(AIAgent agent, int agentIndex) { throw new System.NotImplementedException(); }
public MoveToAction(AIAgent agent, Vector3 position) : base(agent) { Name = "MoveTo"; _targetPosition = position; }
public GetBallState(AIAgent owner) { _stateDefinition.stateName = StateDefinition.StateName.GetBall; _owner = owner; }
public override void RunTree(AIAgent agent) { throw new System.NotImplementedException(); }
public EatAction(AIAgent agent) : base(agent) { Name = "Eat"; BaseUtility = 5; }
protected override bool Evaluate(AIAgent agent) { var hit = Physics2D.Raycast(transform.position, animationController.direction, maxDistance, layers); return(hit.collider.transform == PlayerTracker.Transform); }
public SleepAction(AIAgent agent) : base(agent) { Name = "Sleep"; BaseUtility = 5; }
protected Action(AIAgent agent, ActorInfo info) { _agent = agent; }
protected Action(AIAgent agent) { _agent = agent; }
public CutLogAction(AIAgent agent) : base(agent) { Name = "Cut the log"; BaseUtility = 5; }
// Use this for initialization void Awake() { owner = GetComponent <AIAgent>(); }
public CollectFoodAction(AIAgent agent) : base(agent) { Name = "Collect food"; BaseUtility = 5; }
public abstract void RunTree(AIAgent agent);
public Attack(AIAgent agent) : base(agent) { }
// Use this for initialization void Awake() { navMeshAgent = GetComponent <NavMeshAgent>(); aiAgent = GetComponent <AIAgent>(); }
/// <param name="agent">the agent that will be acted upon</param> public Action(AIAgent agent) { this.agent = agent; }
// Use this for initialization public ChopTreeAction(AIAgent agent, Tree tree) : base(agent) { Name = "Chop the tree action"; BaseUtility = 5; _tree = tree; }
protected override void Awake() { base.Awake(); _agent = GetComponent<AIAgent>(); StartCoroutine(HandleVitality()); }
public Rebuild(AIAgent agent) : base(agent) { }
/// <summary> /// Cache the component references. /// </summary> private void Awake() { itemHandler = GetComponent <ItemHandler>(); aiAgent = GetComponent <AIAgent>(); }
protected virtual void Awake() { owner = GetComponent <AIAgent>(); }
abstract public void MakeActiveObservation(AIAgent aiAgent);
public TacticsHandler(AIAgent p_aIAgent, TacticsNode p_tacticsNode) { aIAgent = p_aIAgent; tacticsNode = p_tacticsNode; period_left_to_act = p_tacticsNode.responseTime; }
abstract public void ProcessActions(AIAgent aiAgent);
void AIState.Exit(AIAgent agent) { }
abstract public void ProcessObservations(AIAgent aiAgent);
public void Create() { aiAgent = new AIAgent(); steeringBehaviour = new SteeringBehaviour(aiAgent); m_pHeadingSmoother = new Smoother(Prm.NumSamplesForSmoothing, Vector3.zero); }
public WakeUpAction(AIAgent agent) : base(agent) { Name = "Wake up"; BaseUtility = 5; }
public override void Init(AIAgent owner) { base.Init(owner); }
public ThrowBallState(AIAgent owner) { _stateDefinition.stateName = StateDefinition.StateName.ThrowBall; _owner = owner; }
private void SetupData() { aiAgent = Object.FindObjectOfType <AIAgent <L, V> >(); goals = aiAgent.Goals.GetGoals(); actions = aiAgent.Actions.GetActions(); }
// Update is called once per frame void Update() { if (GameLogic.instance.gameState != GameLogic.GameStates.gameplay) { return; } if (state == States.attacking) { if (!Input.GetButton("Drain")) { StopDrain(); } } if (canDrain && Input.GetButtonDown("Drain") && (state == States.idle || state == States.moving)) { StopMovement(); drainObject.SetActive(true); SetState(States.attacking); RaycastHit hit; if (Physics.Raycast(transform.position, transform.forward, out hit, drainRange, enemyLayerMask)) { Debug.Log("Hit " + hit.transform.gameObject.name); AIAgent agent = hit.transform.gameObject.GetComponent <AIAgent>(); if (agent != null && agent.aiSight.sightState != AISight.SightStates.seeingEnemy) { agent.OnDrainStart(); Debug.Log("Draining "); // drainObject.SetActive(true); // SetState(States.attacking); drainTarget = agent; } } else { Debug.Log("No hit"); } } if (canShock && energy >= shockCost && Input.GetButtonDown("Shock") && (state == States.idle || state == States.moving)) { SpendEnergy(shockCost); threadController.moving = false; SetState(States.shocking); StopMovement(); GameObject thisShockObject = GameObject.Instantiate(shockObject); thisShockObject.transform.position = transform.position; StartCoroutine(shockRoutine()); } if (canCloak && Input.GetButtonDown("Cloak") && (state == States.idle || state == States.moving)) { normalModel.SetActive(false); cloakedModel.SetActive(true); cloaked = true; rb.velocity = Vector3.zero; threadController.moving = false; } else { if (cloaked && !Input.GetButton("Cloak")) { cloaked = false; normalModel.SetActive(true); cloakedModel.SetActive(false); } } if (canShoot && Input.GetButtonDown("Shoot") && (state == States.idle || state == States.moving)) { SpendEnergy(shootCost); Fire(); } if (canHover && Input.GetButton("Hover") && (state == States.idle || state == States.moving)) { normalModel.SetActive(false); cloakedModel.SetActive(true); hovering = true; var pos = transform.position; pos.y = hoverHeight; transform.position = pos; if (!hoverParticles.isPlaying) { rb.useGravity = false; hoverParticles.Play(); hoverAudio.Play(); var ppos = hoverParticles.transform.position; ppos.y = 0; hoverParticles.transform.position = ppos; } } else { if (hovering && !Input.GetButton("Hover")) { hovering = false; normalModel.SetActive(true); cloakedModel.SetActive(false); if (hoverParticles.isPlaying) { rb.useGravity = true; hoverAudio.Stop(); hoverParticles.Stop(); var ppos = hoverParticles.transform.position; ppos.y = 0; hoverParticles.transform.position = ppos; } } } if (state == States.idle && !cloaked) { moving = false; inputVector = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")); inputVector = Vector3.ClampMagnitude(inputVector, 1.0f); float camRotation = cam.transform.rotation.eulerAngles.y; inputVector = getMovementDirection(inputVector, camRotation); //rb.velocity = new Vector3(Mathf.Max(0.0f,rb.velocity.x * (1.0f - Time.deltaTime)), rb.velocity.y, Mathf.Max(0.0f, rb.velocity.z * (1.0f - Time.deltaTime))); rb.velocity = new Vector3(0, rb.velocity.y, 0); if (Input.GetButton("Run")) { running = true; threadController.speed = threadRunSpeed; threadController.audioSource.pitch = 1.25f; } else { running = false; threadController.speed = threadWalkSpeed; threadController.audioSource.pitch = 1.0f; } if (inputVector.magnitude > 0.1f) { threadController.moving = true; if (!running) { if (runParticles.isPlaying) { runParticles.Stop(); } if (!walkParticles.isPlaying) { walkParticles.Play(); } } else { if (walkParticles.isPlaying) { walkParticles.Stop(); } if (!runParticles.isPlaying) { runParticles.Play(); } } moving = true; applyMovement(inputVector); rotate(inputVector); } else { if (walkParticles.isPlaying) { walkParticles.Stop(); } if (runParticles.isPlaying) { runParticles.Stop(); } threadController.moving = false; } // if (hovering) // { // var pos = transform.position; // pos.y = hoverHeight; // transform.position = pos; // } } if (enableEnergyDrain) { float energyDrain = energyDrainSpeed * Time.deltaTime; if (energy <= maxEnergy * lowEnergyFraction) { energyDrain = energyDrain * lowEnergyMultiplier; } if (running) { energyDrain = energyDrain * runningEnergyMultiplier; } if (cloaked) { energyDrain = energyDrain * cloakingEnergyMultiplier; } if (hovering) { energyDrain = energyDrain * hoveringEnergyMultiplier; } if (!moving) { energyDrain = energyDrain * standingEnergyMultiplier; } if (state == States.attacking) { if (drainTarget == null) { energyDrain = energyDrain * drainingEnergyMultiplier; } else { energyDrain = 0; } } energy -= energyDrain; energyBar.UpdateBar(energy); UpdateEnergyColor(energy / maxEnergy); if (energy <= 0) { GameLogic.instance.GameOver(); } } }
private void Awake() { base.Awake(); _agent = GetComponent<AIAgent>(); }
public void Init(FCObject eb) { _owner = eb as AIAgent; _eotList.Clear(); _eotFlag = 0; }
void FixedUpdate() { if (currentScreen != null) //test stuff inside! will need to be rewritten for actual game { currentScreen.show(); if (currentScreen is Field) { bool goToBuildHub = false; GameEngine gameEngine = null; Robot humanRobotOnField = null; if (!gameOver) { gameEngine = ((Field)currentScreen).getGameEngine(); humanRobotOnField = ((Field)currentScreen).getHumanRobot(); } if (humanRobotOnField != null && humanRobotOnField.getRemainingDurability() != currentHumanRobotHealth) { humanRobot = humanRobotOnField; currentHumanRobotHealth = humanRobotOnField.getRemainingDurability(); foreach (Part part in humanRobotOnField.getParts()) { int partIndex = humanRobotParts.FindIndex(p => p.getID() == part.getID()); humanRobotParts[partIndex].damage(humanRobotParts[partIndex].getRemainingDurability() - part.getRemainingDurability()); } updatePlayerData(credits, humanRobotParts, myRobots, obstaclesData); } if (gameEngine != null && gameEngine.isRoundOver()) { gameOver = true; goToBuildHub = ((Field)currentScreen).getGoToBuildHub(); double[] roundOverData = gameEngine.getRoundOverData(); double roundDamageDifference = roundOverData[(int)ROUND_OVER_DATA_TYPES.ROUND_DAMAGE_DIFFERENCE]; double roundMaxDamageDifference = roundOverData[(int)ROUND_OVER_DATA_TYPES.ROUND_MAX_DAMAGE_DIFFERENCE]; double roundTimeElapsed = roundOverData[(int)ROUND_OVER_DATA_TYPES.ROUND_TIME_ELAPSED]; long performanceMetric = PERFORMANCE_METRIC_CALCULATOR.calculatePerformanceMetric(roundDamageDifference, roundMaxDamageDifference, roundTimeElapsed, previousRoundDamageDifference, previousRoundMaxDamageDifference, previousRoundTimeElapsed); if (performanceMetric > 0) { experience += performanceMetric; credits += performanceMetric; } ObstacleGenerator obstacleGenerator = new ObstacleGenerator(experience, settingsManager.getSettingPairs(currentSettings).max_obstacles, fieldSize); obstaclesData.Clear(); obstaclesData.AddRange(obstacleGenerator.getObstaclesData()); updatePlayerData(experience, credits, humanRobotParts, myRobots, obstaclesData, roundDamageDifference, roundMaxDamageDifference, roundTimeElapsed); Robot bestAIAgentBot = gameEngine.getBestNonHumanRobot(); if (bestAIAgentBot != null && !bestAIAgentBot.isHuman()) { List <AIAgent> agents = new List <AIAgent>(); agents.AddRange(aiManager.getAgents()); aiManager.applyBuildHubRewards(); AIAgent bestAIAgent = agents.Find(agent => agent.getBot().getName() == bestAIAgentBot.getName()); List <BuildHubState> buildHubStates = bestAIAgent.getBuildHubStates(); List <FieldState> fieldStates = bestAIAgent.getFieldStates(); List <BuildHubStateData> buildHubStateDataList = new List <BuildHubStateData>(); List <FieldStateData> fieldStateDataList = new List <FieldStateData>(); foreach (BuildHubState buildHubState in buildHubStates) { buildHubStateDataList.Add(buildHubStateDataManager.stateToStateData(buildHubState)); } buildHubStatesData = buildHubStateDataList; foreach (FieldState fieldState in fieldStates) { fieldStateDataList.Add(fieldStateDataManager.stateToStateData(fieldState)); } fieldStatesData = fieldStateDataList; stateDataHasUpdated = true; } gameEngine.destroyAllGeneratedObjects(); gameEngine = null; } else if (gameEngine != null && gameEngine.isGamePlay()) { aiManager.update(); FieldAction[] agentActions = aiManager.getFieldActionsToPerform(); AIAgent[] aiAgents = aiManager.getAgents(); for (int agentIndex = 0; agentIndex < agentActions.Length; ++agentIndex) { gameEngine.triggerAction(aiAgents[agentIndex].getBot(), agentActions[agentIndex]); } } if (currentTest == TESTS.AI_AGENT_TRAINING && gameEngine == null) { screenChangingFrom = currentScreen; currentScreen = null; switchScene(typeof(Field)); //enable below when done with single-round testing of AI Agent Training //currentScreen = null; //switchScene(typeof(Field)); } else if (goToBuildHub || (currentScreen != null && gameEngine != null && ((Field)currentScreen).getGoToBuildHub())) { trainingMode = false; screenChangingFrom = currentScreen; currentScreen = null; switchScene(typeof(BuildHub)); } } else if (currentScreen is BuildHub) { humanRobot = ((BuildHub)currentScreen).getCurrentRobot(); updatePlayerData(((BuildHub)currentScreen).getUpdatedCredits(), ((BuildHub)currentScreen).getHumanRobotParts(), ((BuildHub)currentScreen).getMyRobotsList(), obstaclesData); if (((BuildHub)currentScreen).getGoToField()) { trainingMode = ((BuildHub)currentScreen).getTrainingMode(); screenChangingFrom = currentScreen; currentScreen = null; switchScene(typeof(Field)); } } if (currentScreen != null && currentScreen.areSettingsOpen()) { updateSettings(currentScreen.getSettings()); } } }
protected abstract void Update(AIAgent agent);
public void Initialize(AIAgent agent) { _aiWeapon = agent.GetComponent <AIWeapons>(); _agent = agent; }
public StandIdleAction(AIAgent agent, float idleTime = 3f) : base(agent) { Name = "Stand Idle"; BaseUtility = 6; _idleTime = idleTime; }