private void Start() { //Inicializamos variables enemyMovement = GetComponent <EnemyMovement>(); rb = GetComponent <Rigidbody2D>(); col = GetComponent <CapsuleCollider2D>(); anim = GetComponent <Animator>(); //Inicializamos las estadísticas según el ScriptableObject EnemyStats actualHealth = stats.healthPoints; shootingCooldown = stats.rangeAttackRate; meleeCooldown = stats.meleeSpeedAttack; spawnPoint = transform; if (patrolWaypoints.Length == 0) { enemyMovement.target = this.transform; //ENEMIGO ESTÁTICO } else { enemyMovement.target = patrolWaypoints[0]; //ENEMIGO QUE PATRULLA } //Seleccionamos el primer estado como el estado PATRULLA (Estado base de nuestro enemigo) currentState = patrolState; }
/// <summary> /// Moves the specified waypoint of target to your position (int Id) /// </summary> /// <param name="plr">Player that initiated the command</param> /// <param name="values">List of command arguments (after command name)</param> /// <returns>True if command was correctly handled, false if operation was canceled</returns> public static bool NpcMoveWaypoint(Player plr, ref List <string> values) { Object target = plr.CbtInterface.GetCurrentTarget(); if (target == null || !target.IsCreature()) { return(false); } int id = GetInt(ref values); AIInterface ia = target.GetCreature().AiInterface; Waypoint wp = ia.GetWaypoint(id); if (wp == null) { plr.SendMessage(0, "Server", "Invalid Waypoint ID. Use .waypoint list", ChatLogFilters.CHATLOGFILTERS_SHOUT); return(true); } wp.X = (ushort)plr.X; wp.Y = (ushort)plr.Y; wp.Z = (ushort)plr.Z; ia.SaveWaypoint(wp); List <string> empty = null; return(NpcListWaypoint(plr, ref empty)); }
protected ABrain(Unit unit) { _unit = unit; Combat = (CombatInterface_Npc)unit.CbtInterface; AI = unit.AiInterface; _pet = unit as Pet; }
public void ChangeState(AIInterface newState) { if (CurrentState != null) { CurrentState.Exit(); } CurrentState = newState; CurrentState.Enter(this); }
public Player(string name, StatsContainer coreInfo, AIInterface brain) { this.name = name; //this.actions = actions; slimes = new List <Slime>(); conqueredTiles = new List <Tile>(); this.statsCoreInfo = coreInfo; SetBrain(brain); isAI = true; this.id = ID; ID++; }
/// <summary> /// 実際にAIを走らせてタイムを計測します。 /// </summary> /// <param name="runner">AI</param> /// <param name="orig">盤面</param> /// <returns>AIの着手</returns> public int[] RunClock(AIInterface runner, Board orig) { //AI始動 var res = RunProgram(runner, new Board(orig)); if (timers[runner] < 0) { Logger.String(string.Format(" {0} Timed out.", runner.Name)); orig.Shutdown(); } return res.Result; }
private void UseAI(AIInterface ai) //AI操作函数 { int now = 1; if (gameTurn != GameTurn.Black) { now = 2; } CopyBoard(); ai.Running(_board, now); int x, y; ai.GetNextStep(out x, out y); PutPiece(x, y); }
/// <summary> /// Shows information about the current waypoint. /// </summary> /// <param name="plr">Player that initiated the command</param> /// <param name="values">List of command arguments (after command name)</param> /// <returns>True if command was correctly handled, false if operation was canceled</returns> public static bool NpcInfoWaypoint(Player plr, ref List <string> values) { Object target = plr.CbtInterface.GetCurrentTarget(); if (target == null || !target.IsCreature()) { return(false); } AIInterface ia = target.GetCreature().AiInterface; string message = ""; message += "Current = " + ia.CurrentWaypointID + ",NextTime=" + (ia.NextAllowedMovementTime - TCPManager.GetTimeStampMS()) + ",Started=" + ia.Started + ",Ended=" + ia.Ended + ",Back=" + ia.IsWalkingBack + ",Type=" + ia.CurrentWaypointType + ",State=" + ia.State; plr.SendMessage(0, "Server", message, ChatLogFilters.CHATLOGFILTERS_SHOUT); return(true); }
/// <summary> /// Shows the list of waypoints. /// </summary> /// <param name="plr">Player that initiated the command</param> /// <param name="values">List of command arguments (after command name)</param> /// <returns>True if command was correctly handled, false if operation was canceled</returns> public static bool NpcListWaypoint(Player plr, ref List <string> values) { Object target = plr.CbtInterface.GetCurrentTarget(); if (target == null || !target.IsCreature()) { return(false); } AIInterface ia = target.GetCreature().AiInterface; string message = "Waypoints :" + ia.Waypoints.Count + "\n"; foreach (Waypoint wp in ia.Waypoints) { message += wp + "\n"; } plr.SendMessage(0, "Server", message, ChatLogFilters.CHATLOGFILTERS_SHOUT); return(true); }
private async Task<int[]> RunProgram(AIInterface runner, Board orig) { Stopwatch sw = new Stopwatch(); sw.Start(); var task = Task.FromResult<int[]>(runner.Solve(orig)); var res = await task; sw.Stop(); long time = sw.ElapsedMilliseconds / 1000; if (time > handSec) { timers[runner] -= (time - handSec); } Logger.String(string.Format(" {0} used {1} seconds({3} ms), Left {2} seconds", runner.Name, time, timers[runner], sw.ElapsedMilliseconds)); return res; }
public ClientFacade(string playerName, string roomName = "default") { this.PlayerName = playerName; this.RoomName = roomName; // Initialize follows // io serverHolder = new TCPServerHolder(); serverHolder.OnGetMessageFromServer += MessageFromServerHandler; // logger // router clientRouter = new ClientRouter(); clientRouter.OnAgari += OnHora; clientRouter.OnAnkan += OnAnkan; clientRouter.OnChi += OnChi; clientRouter.OnDaiminkan += OnDaiminkan; clientRouter.OnDropPai += OnDahai; clientRouter.OnEndGame += OnEndGame; clientRouter.OnEndKyoku += OnEndKyoku; clientRouter.OnGetPai += OnTsumo; clientRouter.OnHello += OnHello; clientRouter.OnKakan += OnKakan; clientRouter.OnOpenDora += OnDora; clientRouter.OnPon += OnPon; clientRouter.OnReach += OnReach; clientRouter.OnReachAccepted += OnReachAccepted; clientRouter.OnRyukyoku += OnRyukyoku; clientRouter.OnStartGame += OnStartGame; clientRouter.OnStartKyoku += OnStartKyoku; clientRouter.OnSetScene += OnSetScene; //Mjmodel clientMjModel = new ClientMjModel(); ai = new MinShantenAI(); SetServerHolderToAI(serverHolder); }
public void TakeDamage(int damage, Vector2 knockback) { if (dead) { return; } if (hitAudio != null) { hitAudio.Play(); } //Los enemigos estáticos no pueden ser desplazados con nuestros ataques. if (stats.canMove) { rb.constraints = RigidbodyConstraints2D.FreezeRotation; } else { rb.constraints = RigidbodyConstraints2D.FreezeAll; } //Si al recibir el daño, el enemigo cae a 0 o menos, ejecutamos la función de morir (Die()); // en caso contrario aplicamos el knockback y la animación pertinente; y seleccionamos que pase al estado Chase (Persecución) actualHealth -= damage; if (actualHealth <= 0) { Die(); } else { anim.SetTrigger("hit"); rb.AddForce(knockback); enemyMovement.target = player; currentState = chaseState; } }
public void UseLLSAI() { ai = new LLSAI(instance); actionTimer.Interval = 1000*5; }
public void UseMysticAI() { ai = new MysticAI(instance); actionTimer.Interval = 1000 * 3600; }
public void Register(AIInterface ai) { timers[ai] = playerSec; }
public void SetBrain(AIInterface brain) { isAI = true; this.brain = brain; }
public void UseNormalAI() { ai = new NormalAI(instance); actionTimer.Interval = 1000 * 3600; }
public void SetAI(AIInterface ai) { this.ai = ai; }