public void Action(MyAI _player) { if (this.NPNumber == -1) { this.NPoint = _player.GetNextUndoneNavPoint(this.Location, ref this.NPNumber); } if (_player.NavigationPoints[NPNumber].Complete == true) { this.NPoint = _player.GetNextUndoneNavPoint(this.Location, ref this.NPNumber); this.StopMoving(); } if ((this.Location == this.NPoint) && (_player.CurrentTurn > _player.NavigationPoints[NPNumber].StartTurn) && (_player.CurrentTurn < _player.NavigationPoints[NPNumber].EndTurn)) { _player.NavigationPoints[NPNumber].Complete = true; } if (this.State == NanoBotState.WaitingOrders) { if (this.Location != this.NPoint) { this.MoveTo(NPoint); //this.MoveTo(_player.ePathfinder.FindPath(this.Location,this.NPoint)); return; } } }
// 受伤 public override void getHurt(DamageDegree damageDegree, float damage, DamageType damageType) { base.getHurt(damageDegree, damage, damageType); Locked = true; Invoke("cure", 0.5f); MyAI.setState(AIState.HURT); }
public void Action(MyAI _player) { active = false; if (_player.OtherNanoBotsInfo != null) { foreach (NanoBotInfo botEnemy in _player.OtherNanoBotsInfo) { if (!((botEnemy.NanoBotType == NanoBotType.NanoBlocker) || (botEnemy.NanoBotType == NanoBotType.NanoNeedle) || (botEnemy.NanoBotType == NanoBotType.NanoNeuroControler))) { if (_player.GeomDist(this.Location, botEnemy.Location) <= Utils.BlockerStrength) { active = true; } } } } if (_player.OtherInjectionPointsInfo != null) { foreach (InjectionPointInfo ip in _player.OtherInjectionPointsInfo) { if (_player.GeomDist(this.Location, ip.Location) <= Utils.BlockerStrength) { active = true; } } } if (!active) { this.ForceAutoDestruction(); } }
public override BTResult Process() { if (MyParty == null) { return(Exit(BTResult.Fail)); } if (MyParty.IsPlayerParty) { if (MyAI.MyShip == GameManager.Inst.PlayerControl.PlayerShip) { MyAI.OnTravelCompletion(); } return(Exit(BTResult.Fail)); } MacroAITaskType prevType = MacroAITaskType.None; if (MyParty.CurrentTask != null) { prevType = MyParty.CurrentTask.TaskType; } GameManager.Inst.NPCManager.MacroAI.AssignMacroAITask(prevType, MyParty); return(Exit(BTResult.Success)); }
public void Action(MyAI _player, int NextHPnum) { //Если AI уже сам всё видит, идём дальше if (_player.GeomDist(_player.HoshimiPoints[NextHPnum].Location, _player.AI.Location) < Utils.ScanLength + _player.AI.Scan) { for (int i = 0; i < _player.MyHPs.Count - 1; i++) { if (NextHPnum == (int)_player.MyHPs[i]) { dest = (int)_player.MyHPs[i + 1]; this.StopMoving(); this.MoveTo(_player.ePathfinder.FindPath(this.Location, _player.HoshimiPoints[dest].Location)); return; } } } if (dest != NextHPnum) { dest = NextHPnum; this.StopMoving(); } this.MoveTo(_player.ePathfinder.FindPath(this.Location, _player.HoshimiPoints[dest].Location)); return; }
public void Action(MyAI _player) { //NPNumber == -10 означает, что все NavigationObjectives уже выполнены if (this.NPNumber == -10) { this.ForceAutoDestruction(); return; } //NPNumber == -1 означает, что навигатор только появился, и ему надо назначить цель if (this.NPNumber == -1) { //this.NPoint = _player.GetNearestUndoneNavPoint(this.Location, ref this.NPNumber); this.NPoint = _player.GetNextUndoneNavPoint(this.Location, ref this.NPNumber); if (this.NPNumber == -10) { this.ForceAutoDestruction(); return; } } //Если вдруг обнаруживаем, что цель, к которой идём, уже кем-то посещена, то запрашиваем новую и останавливаемся. if (_player.NavigationPoints[NPNumber].Complete == true) { //this.NPoint = _player.GetNearestUndoneNavPoint(this.Location, ref this.NPNumber); this.NPoint = _player.GetNextUndoneNavPoint(this.Location, ref this.NPNumber); if (this.NPNumber == -10) { this.ForceAutoDestruction(); return; } this.StopMoving(); } //Если мы стоим на цели в нужное время, то помечаем её как выполненную и запрашиваем новую. if ((this.Location == this.NPoint) && (_player.CurrentTurn > _player.NavigationPoints[NPNumber].StartTurn) && (_player.CurrentTurn < _player.NavigationPoints[NPNumber].EndTurn)) { _player.NavigationPoints[NPNumber].Complete = true; this.NPoint = _player.GetNextUndoneNavPoint(this.Location, ref this.NPNumber); if (this.NPNumber == -10) { this.ForceAutoDestruction(); return; } } //Если мы стоим, причём не на своей текущей цели, то идём к ней самой. if (this.State == NanoBotState.WaitingOrders) { if (this.Location != this.NPoint) { //MoveTo(NPoint); MoveTo(_player.ePathfinder.FindPath(this.Location, NPoint)); return; } } }
//Отвечает за анализ обстановки и стрельбу. //Возвращает ответ на вопрос "Грозит ли AI опасность?" public bool Alarm(MyAI _player) { bool ahtung = false; double Distance; double MinDistance; Point ShootAt = new Point(); //Если в пределах досягаемости кто-то есть, останавливаемся if (_player.OtherNanoBotsInfo != null) { foreach (NanoBotInfo botEnemy in _player.OtherNanoBotsInfo) { if (botEnemy.PlayerID == 0) { Distance = _player.GeomDist(botEnemy.Location, this.Location); if (Distance <= this.DefenseDistance) { this.StopMoving(); //И запоминаем, что надо предупредить AI об опасности. ahtung = true; } } } } //Если стоим if (this.State == NanoBotState.WaitingOrders) { //Ищем ближайшую цель MinDistance = 1000; if (_player.OtherNanoBotsInfo != null) { foreach (NanoBotInfo botEnemy in _player.OtherNanoBotsInfo) { if (botEnemy.PlayerID == 0) { Distance = _player.GeomDist(botEnemy.Location, this.Location); if ((botEnemy.NanoBotType == NanoBotType.NanoAI) && (Distance < this.DefenseDistance)) { MinDistance = -1; ShootAt = botEnemy.Location; } if (Distance < MinDistance) { MinDistance = Distance; ShootAt = botEnemy.Location; } } } } //Если она достаточно близко, стреляем и завершаем действия if (MinDistance <= this.DefenseDistance) { this.DefendTo(ShootAt, 3); return(ahtung); } } return(ahtung); }
protected override AICharacter RandomBuild(Pg.Level level) { var lvl = ((int)level); Name = Name.ValueIfNotNullOrElse("Orc"); // God - can be null Stats = Stats.ValueIfNotNullOrElse(new GodsWill_ASCIIRPG.Stats( StatsBuilder.RandomStats( new Dictionary <StatsType, int>() { { StatsType.Strength, 2 }, { StatsType.Toughness, 2 }, { StatsType.Mental, -2 }, { StatsType.InnatePower, -2 }, }))); var toughMod = ((Stats)Stats)[StatsType.Toughness].ModifierOfStat(); MaximumPf = CurrentPf.ValueIfNotNullOrElse(Orc.healthDice.Max + Dice.Throws(Orc.healthDice, lvl) + lvl * toughMod); CurrentPf = MaximumPf.ValueIfNotNullOrElse((int)MaximumPf); Hunger = Hunger.ValueIfNotNullOrElse((Orc.hungerDice.Max + Dice.Throws(Orc.hungerDice, lvl)) * toughMod); MyAI = MyAI.ValueIfNotNullOrElse(new SimpleAI()); MySensingMethod = MySensingMethod.ValueIfNotNullOrElse(AI.SensingAlgorythms.AllAround); PerceptionDistance = PerceptionDistance.ValueIfNotNullOrElse(5); //WornArmor - Can be null //EmbracedShield - Can be null //HandledWeapon - Can be null Backpack = Backpack.ValueIfNotNullOrElse(new Backpack()); Symbol = Symbol.ValueIfNotNullOrElse("o"); Color = Color.ValueIfNotNullOrElse(System.Drawing.Color.DarkOliveGreen); Description = Description.ValueIfNotNullOrElse("A greenish, smelly human-like creature. Strong, but usually not very smart."); Position = Position.ValueIfNotNullOrElse(new Coord()); AlliedTo = AlliedTo.ValueIfNotNullOrElse(Allied.Enemy); var orc = new Orc(Name, (int)CurrentPf, (int)MaximumPf, (int)Hunger, MyAI, MySensingMethod, (int)PerceptionDistance, (Stats)Stats, WornArmor, EmbracedShield, HandledWeapon, Backpack, God, Symbol, (System.Drawing.Color)Color, Description, (Coord)Position, (Allied)AlliedTo); return(orc); }
// Use this for initialization void Start() { objCaronteNPC.SetActive(true); objCaronteBriga.SetActive(false); validaAtivaCaronte = true; scriptPlayerController = (MyPlayerController)objPlayer.transform.GetComponent("MyPlayerController"); scriptAICaronte = (MyAI)objCaronteBriga.transform.GetComponent("MyAI"); boolValidaMorte = true; }
public override void OnStateEnter(Animator animator, AnimatorStateInfo animatorStateInfo, int layerIndex) { ai = animator.GetComponent <MyAI>(); ai.stopMove = true; //Debug.Log(dialogue[dialogueIndex]); //ai.talkLock = true; tree = animator.transform.root.GetComponent <DialogueTreeContainer>(); }
public AStarPathfinder(MyAI _player) { Xdim = _player.Tissue.Width; Ydim = _player.Tissue.Height; Map = new node[Xdim, Ydim]; States = new int[Xdim, Ydim]; fs = new double[Xdim, Ydim]; GetMap(Xdim, Ydim, _player); }
// Use this for initialization void Start() { objCaronteNPC.SetActive(true); objCaronteBriga.SetActive(false); validaAtivaCaronte = true; scriptPlayerController = (MyPlayerController) objPlayer.transform.GetComponent("MyPlayerController"); scriptAICaronte = (MyAI) objCaronteBriga.transform.GetComponent("MyAI"); boolValidaMorte = true; }
private int GetStreamDirection(MyAI _player, Point p) { BloodStream stream = _player.Tissue.IsInStream(p.X, p.Y); if (stream != null) { return((int)stream.Direction); } return(-1); }
//Эту функцию вызывают извне при записывании дефендера в конвой public void SetConvoyNumber(MyAI _player) { ConvoyNumber = _player.GetConvoyNumberForConvoyWithBigContainer(); if (ConvoyNumber != -1) { _player.BigConvoys[ConvoyNumber].Defenders++; _player.BigConvoys[ConvoyNumber].AddBot(this); } //string str = "Defender belongs to convoy " + this.ConvoyNumber.ToString() + "\n"; //Debugger.Log(2, "Local", str); }
// Update is called once per frame void Update() { MyAI AI = (MyAI)GetComponent("MyAI"); if (AI) { if (AI.IsDead) { particula.SetActive(true); } } }
void Update() { scriptAICaronte = (MyAI) objCaronteBriga.transform.GetComponent("MyAI"); if(boolValidaMorte){ if(scriptAICaronte.IsDead){ objPlayer.SendMessage("mensagemCaronteDerrotadoOn"); objBarco.SendMessage("ativar"); boolValidaMorte = false; } } }
void Update() { scriptAICaronte = (MyAI)objCaronteBriga.transform.GetComponent("MyAI"); if (boolValidaMorte) { if (scriptAICaronte.IsDead) { objPlayer.SendMessage("mensagemCaronteDerrotadoOn"); objBarco.SendMessage("ativar"); boolValidaMorte = false; } } }
public override void Initialize() { //load aim target and look target GameObject aimTarget = (GameObject)GameObject.Instantiate(Resources.Load("IKAimTargetRoot")); GameObject lookTarget = (GameObject)GameObject.Instantiate(Resources.Load("IKLookTarget")); AimTargetRoot = aimTarget.transform; AimTarget = AimTargetRoot.Find("IKAimTarget").transform; LookTarget = lookTarget.transform; LoadCharacterModel(this.CharacterID); this.MyEventHandler = GetComponent <CharacterEventHandler>(); this.Destination = transform.position; MyNavAgent = GetComponent <UnityEngine.AI.NavMeshAgent>(); UpperBodyState = MutantUpperBodyStates.Idle; ActionState = HumanActionStates.None; this.MyStatus = GetComponent <CharacterStatus>(); this.MyStatus.ParentCharacter = this; //this.MyStatus.Initialize(); this.MyStatus.RunSpeedModifier = 1f; this.Stealth = new CharacterStealth(this); this.Inventory = new CharacterInventory(); this.CharacterAudio = GetComponent <AudioSource>(); //each time a human char is initialized it's added to NPC manager's list of human characters to keep track of GameManager.Inst.NPCManager.AddMutantCharacter(this); CurrentAnimState = new MutantAnimStateIdle(this); //SendCommand(CharacterCommands.Unarm); this.GoapID = this.MyReference.GoapID; MyAI = GetComponent <AI>(); MyAI.Initialize(this); this.ArmorSystem = new ArmorSystem(this); _meleeStrikeStage = 0; }
public override void OnStateEnter(Animator animator, AnimatorStateInfo animatorStateInfo, int layerIndex) { hasEnded = false; waypointIndex = 0; routelist = animator.GetComponent <RouteList>(); ai = animator.GetComponent <MyAI>(); if (!alreadySubbed) { ai.OnFinishPath += NextPoint; alreadySubbed = true; } statemachine = animator; ai.SetDestination(routelist.routes[routeSelect].GetGlobalPoint(waypointIndex)); ai.stopMove = false; }
//Собраться вместе, если по каким-то причинам всё-таки разделились. //Теоретически не нужна. Может понадобиться только в случае лагов, //если вдруг часть конвоя походит, а часть нет. private void Gather(MyAI _player) { if (MyDefender != null) { MyDefender.StopMoving(); MyDefender.MoveTo(_player.Pathfinder.FindPath(MyDefender.Location, this.Location)); } if (MyContainer[0] != null) { MyContainer[0].StopMoving(); MyContainer[0].MoveTo(_player.Pathfinder.FindPath(MyContainer[0].Location, this.Location)); } if (MyContainer[1] != null) { MyContainer[1].StopMoving(); MyContainer[1].MoveTo(_player.Pathfinder.FindPath(MyContainer[1].Location, this.Location)); } }
public override void OnStateEnter(Animator animator, AnimatorStateInfo animatorStateInfo, int layerIndex) { ai = animator.GetComponent <MyAI>(); ai.OnFinishPath = NextPoint; Vector2 p = Random.insideUnitCircle.normalized; p = p * 2; p = (Vector2)animator.transform.position + p; NNInfo info = AstarPath.active.GetNearest(p); Vector3 closest = info.position; ai.SetDestination(closest); }
public void Action(MyAI _player) { //Запоминаем, на каком HP мы стоим if (HPNumber == -1) { for (int i = 0; i < _player.HoshimiPoints.Length; i++) { if (_player.HoshimiPoints[i].Location == this.Location) { HPNumber = i; } } } //Проверяем, где враги MinDistance = 1000; if (_player.OtherNanoBotsInfo != null) { foreach (NanoBotInfo botEnemy in _player.OtherNanoBotsInfo) { if (botEnemy.PlayerID == 0) { Distance = _player.GeomDist(botEnemy.Location, this.Location); if (Distance < MinDistance) { MinDistance = Distance; ShootAt = botEnemy.Location; } } } } //Если кто-то достаточно близко - стреляем if (MinDistance < DefenseDistance) { this.DefendTo(ShootAt, 4); return; } }
public override void OnStateEnter(Animator animator, AnimatorStateInfo animatorStateInfo, int layerIndex) { ai = animator.GetComponent <MyAI>(); player = GameObject.FindGameObjectWithTag("Player").transform; }
public void Action(MyAI _player) { if (this.HPNumber == -1) { this.HPoint = _player.GetNextHoshimiPoint(this.Location, ref this.HPNumber); } if (this.HPNumber == -10) { this.HPoint = _player.GetNearestUnfilledHP(this.Location, ref this.HPNumber); } if (HPNumber >= 0) { if (_player.HoshimiPoints[HPNumber].Full == 1) { this.HPoint = _player.GetNearestUnfilledHP(this.Location, ref this.HPNumber); this.StopMoving(); } } if (this.State == NanoBotState.WaitingOrders) { if (this.Location == this.APoint) { if (this.Stock == 0) { //Collect CollectFrom(Location, this.ContainerCapacity / this.CollectTransfertSpeed); return; } else { //Go Hoshimi point //MoveTo(this.HPoint); //string str = "Collector[" + this.ID.ToString() + "] at AP X: " + this.Location.X.ToString() + " Y: " + this.Location.Y.ToString() + "\n"; //Debugger.Log(2, "Local", str); MoveTo(_player.Pathfinder.FindPath(this.Location, this.HPoint)); return; } } if (this.Location == this.HPoint) { foreach (NanoBot bot in _player.NanoBots) { if ((bot is Needle) && (bot.Stock == bot.ContainerCapacity) && (bot.Location == this.Location)) { if (HPNumber >= 0) { _player.HoshimiPoints[HPNumber].Full = 1; this.HPoint = _player.GetNearestUnfilledHP(this.Location, ref this.HPNumber); //Добавить возможность "дозаправки"!!! if (Stock == 0) { this.APoint = _player.GetNearestAZNPoint(this.Location, this.HPoint); //MoveTo(this.APoint); //string str = "Empty collector[" + this.ID.ToString() +"] at finished HP X: " + this.Location.X.ToString() + " Y: " + this.Location.Y.ToString() + "\n"; //Debugger.Log(2, "Local", str); MoveTo(_player.Pathfinder.FindPath(this.Location, this.APoint)); return; } else { //this.MoveTo(this.HPoint); //string str = "Not empty collector[" + this.ID.ToString() +"] at finished HP X: " + this.Location.X.ToString() + " Y: " + this.Location.Y.ToString() + "\n"; //Debugger.Log(2, "Local", str); MoveTo(_player.Pathfinder.FindPath(this.Location, this.HPoint)); return; } } } } if (Stock == 0) { //return to azn this.APoint = _player.GetNearestAZNPoint(this.Location, this.HPoint); //MoveTo(this.APoint); //string str = "Empty collector[" + this.ID.ToString() +"] at HP X: " + this.Location.X.ToString() + " Y: " + this.Location.Y.ToString() + "\n"; //Debugger.Log(2, "Local", str); MoveTo(_player.Pathfinder.FindPath(this.Location, this.APoint)); return; } else { //transfert TransferTo(Location, this.Stock / this.CollectTransfertSpeed); return; } } //Добавить возможность "дозаправки"!!! if (Stock == 0) { //string str = "Empty collector[" + this.ID.ToString() +"] somewhere X: " + this.Location.X.ToString() + " Y: " + this.Location.Y.ToString() + "\n"; //Debugger.Log(2, "Local", str); this.APoint = _player.GetNearestAZNPoint(this.Location, this.HPoint); //this.MoveTo(this.APoint); MoveTo(_player.Pathfinder.FindPath(this.Location, this.APoint)); return; } else { //this.HPoint = _player.GetNearestUnfilledHP(this.Location, ref this.HPNumber); //this.MoveTo(this.HPoint); //string str = "Not empty collector[" + this.ID.ToString() +"] somewhere X: " + this.Location.X.ToString() + " Y: " + this.Location.Y.ToString() + "\n"; //Debugger.Log(2, "Local", str); MoveTo(_player.Pathfinder.FindPath(this.Location, this.HPoint)); return; } } }
private bool GetMap(int X_dimension, int Y_dimension, MyAI _player) { Point p = new Point(); for (int i = 0; i < X_dimension; i++) { for (int j = 0; j < Y_dimension; j++) { p.X = i; p.Y = j; Map[i, j].Location = p; Map[i, j].g = -1; Map[i, j].h = -1; Map[i, j].f = -1; Map[i, j].Number = i * X_dimension + j; Map[i, j].parent = -1; switch ((int)_player.Tissue[i, j].AreaType) { case 0: { Map[i, j].costDown = 2; Map[i, j].costLeft = 2; Map[i, j].costRight = 2; Map[i, j].costUp = 2; Map[i, j].terrain = 2; break; } case 1: { Map[i, j].costDown = 3; Map[i, j].costLeft = 3; Map[i, j].costRight = 3; Map[i, j].costUp = 3; Map[i, j].terrain = 3; break; } case 2: { Map[i, j].costDown = 4; Map[i, j].costLeft = 4; Map[i, j].costRight = 4; Map[i, j].costUp = 4; Map[i, j].terrain = 4; break; } case 3: { Map[i, j].costDown = 6; Map[i, j].costLeft = 6; Map[i, j].costRight = 6; Map[i, j].costUp = 6; Map[i, j].terrain = 6; break; } default: { Map[i, j].costDown = -1; Map[i, j].costLeft = -1; Map[i, j].costRight = -1; Map[i, j].costUp = -1; Map[i, j].terrain = -1; break; } } if (Map[i, j].terrain != -1) { switch (GetStreamDirection(_player, p)) { case 0: { //NorthSouth if (Map[i, j].terrain != 2) { Map[i, j].costLeft -= 2; Map[i, j].costRight -= 2; Map[i, j].costUp -= 2; Map[i, j].costDown += 2; } else { Map[i, j].costLeft -= 1; Map[i, j].costRight -= 1; Map[i, j].costUp -= 1; Map[i, j].costDown += 2; } break; } case 1: { //SouthNorth if (Map[i, j].terrain != 2) { Map[i, j].costLeft -= 2; Map[i, j].costRight -= 2; Map[i, j].costUp += 2; Map[i, j].costDown -= 2; } else { Map[i, j].costLeft -= 1; Map[i, j].costRight -= 1; Map[i, j].costUp += 2; Map[i, j].costDown -= 1; } break; } case 2: { //WestEst if (Map[i, j].terrain != 2) { Map[i, j].costLeft += 2; Map[i, j].costRight -= 2; Map[i, j].costUp -= 2; Map[i, j].costDown -= 2; } else { Map[i, j].costLeft += 2; Map[i, j].costRight -= 1; Map[i, j].costUp -= 1; Map[i, j].costDown -= 1; } break; } case 3: { //EstWest if (Map[i, j].terrain != 2) { Map[i, j].costLeft -= 2; Map[i, j].costRight += 2; Map[i, j].costUp -= 2; Map[i, j].costDown -= 2; } else { Map[i, j].costLeft -= 1; Map[i, j].costRight += 2; Map[i, j].costUp -= 2; Map[i, j].costDown -= 2; } break; } default: { //NoStream break; } } } } } return(true); }
public void Action(MyAI _player) { //Запоминаем, на каком HP мы стоим if (HPNumber == -1) { for (int i = 0; i < _player.HoshimiPoints.Length; i++) { if (_player.HoshimiPoints[i].Location == this.Location) { HPNumber = i; } } } //Проверяем, где враги #region old /* * MinDistance = 1000; * if (_player.OtherNanoBotsInfo != null) * { * foreach (NanoBotInfo botEnemy in _player.OtherNanoBotsInfo) * { * if (botEnemy.PlayerID == 0) * { * Distance = _player.GeomDist(botEnemy.Location, this.Location); * if (Distance < MinDistance) * { * MinDistance = Distance; * ShootAt = botEnemy.Location; * } * } * } * } * //Если кто-то достаточно близко - стреляем * if (MinDistance < DefenseDistance) * { * this.DefendTo(ShootAt, 4); * return; * } * */ #endregion #region new MinDistance = 1000; if (_player.OtherNanoBotsInfo != null) { foreach (NanoBotInfo botEnemy in _player.OtherNanoBotsInfo) { if (botEnemy.PlayerID == 0) { Distance = _player.GeomDist(botEnemy.Location, this.Location); Distance += Utils.DefenseLength; if (Distance < MinDistance) { MinDistance = Distance; ShootAt = botEnemy.Location; } } } } //Если кто-то достаточно близко - стреляем if (MinDistance < DefenseDistance + Utils.DefenseLength) { if (MinDistance < DefenseDistance) { this.DefendTo(ShootAt, 3); return; } else { if (MinDistance >= DefenseDistance && MinDistance < DefenseDistance + Utils.DefenseLength) { Point p = _player.GetTargetOnVector(this.Location, ShootAt, DefenseDistance); this.DefendTo(p, 3); return; } } } #endregion }
public void Action(MyAI _player) { //Если цели ещё нет, то запрашиваем её. if (this.Target.X == -1) { this.Target = _player.GetTargetToAtack(this.Location); } //Проверяем список противников. Если кто-то достаточно близко, останавливаемся. if (_player.OtherNanoBotsInfo != null) { foreach (NanoBotInfo botEnemy in _player.OtherNanoBotsInfo) { if (botEnemy.PlayerID == 0) { Distance = _player.GeomDist(botEnemy.Location, this.Location); if (Distance < this.DefenseDistance) { this.StopMoving(); } } } } if (this.State == NanoBotState.WaitingOrders) { //Ищем ближайшую цель MinDistance = 1000; if (_player.OtherNanoBotsInfo != null) { foreach (NanoBotInfo botEnemy in _player.OtherNanoBotsInfo) { if (botEnemy.PlayerID == 0) { this.Distance = _player.GeomDist(botEnemy.Location, this.Location); //Если вражеский AI достаточно близко, то он пользуется абсолютным приоритетом! if ((botEnemy.NanoBotType == NanoBotType.NanoAI) && (Distance < this.DefenseDistance)) { MinDistance = -1; ShootAt = botEnemy.Location; } if (Distance < MinDistance) { MinDistance = Distance; ShootAt = botEnemy.Location; } } } } //Если противник близко, то стреляем в него. if (MinDistance < this.DefenseDistance) { this.DefendTo(ShootAt, 3); return; } //Идём к цели. if (this.Target != this.Location) { //string str = "Atacker[" + this.ID.ToString() +"] X: " + this.Location.X.ToString() + " Y: " + this.Location.Y.ToString() + "\n"; //Debugger.Log(2, "Local", str); //MoveTo(Target); MoveTo(_player.Pathfinder.FindPath(this.Location, Target)); return; } } }
public void OnDeath(Vector3 normal) { PlayVocal(VocalType.Death); MyAI.OnDeath(); Stealth.OnDeath(); float posture = UnityEngine.Random.Range(0.1f, 200) / 200f; int direction = 1; if (normal != Vector3.zero) { normal = new Vector3(normal.x, 0, normal.z); float angleRight = Vector3.Angle(normal, transform.right); float angleForward = Vector3.Angle(normal, transform.forward); if (angleRight < 60) { direction = 3; } else if (angleRight > 120) { direction = 2; } else { if (UnityEngine.Random.value > 0.5f) { direction = 0; } else { direction = 1; } } } this.MyAnimator.SetInteger("DeathDirection", direction); this.MyAnimator.SetFloat("Blend", posture); this.MyAnimator.SetBool("IsDead", true); CurrentAnimState = new MutantAnimStateDeath(this); IsBodyLocked = true; MyAimIK.solver.SmoothDisable(9); MyLeftHandIK.SmoothDisable(12); MyHeadIK.SmoothDisable(9); MyNavAgent.enabled = false; MyReference.LiveCollider.enabled = false; MyReference.DeathCollider.enabled = true; MyReference.DeathCollider.gameObject.layer = 18; /* * CapsuleCollider collider = GetComponent<CapsuleCollider>(); * collider.height = 0.5f; * collider.radius = 0.6f; * collider.center = new Vector3(0, 0, 0); * collider.isTrigger = true; */ Unhook(); }
public override void OnStateEnter(Animator animator, AnimatorStateInfo animatorStateInfo, int layerIndex) { ai = animator.GetComponent <MyAI>(); ai.stopMove = true; }
public void Action(MyAI _player) { Fire = false; //Проверяем список противников. Если кто-то достаточно близко, останавливаемся. if (_player.OtherNanoBotsInfo != null) { foreach (NanoBotInfo botEnemy in _player.OtherNanoBotsInfo) { if (botEnemy.PlayerID == 0) { Distance = _player.GeomDist(botEnemy.Location, this.Location); if (Distance < this.DefenseDistance) { this.StopMoving(); Fire = true; } } } } //NPNumber == -1 означает, что навигатор только появился, и ему надо назначить цель if (this.NPNumber == -1) { this.NPoint = _player.GetNextUndoneHealPoint(this.Location, ref this.NPNumber); if (this.NPNumber == -10) { this.ForceAutoDestruction(); return; } } if (NPNumber >= 0) { //Если вдруг обнаруживаем, что цель, к которой идём, уже кем-то посещена, то запрашиваем новую и останавливаемся. if (_player.NavigationPoints[NPNumber].Complete == true) { this.NPoint = _player.GetNextUndoneHealPoint(this.Location, ref this.NPNumber); if (this.NPNumber == -10) { this.ForceAutoDestruction(); return; } this.StopMoving(); } } if (NPNumber >= 0) { //Если мы стоим на цели в нужное время, то помечаем её как выполненную и запрашиваем новую. if ((this.Location == this.NPoint) && (_player.CurrentTurn > _player.NavigationPoints[NPNumber].StartTurn) && (_player.CurrentTurn < _player.NavigationPoints[NPNumber].EndTurn) && (this.Stock >= _player.NavigationPoints[NPNumber].Stock)) { _player.NavigationPoints[NPNumber].Complete = true; this.NPoint = _player.GetNextUndoneHealPoint(this.Location, ref this.NPNumber); if (this.NPNumber == -10) { this.ForceAutoDestruction(); return; } } } if (this.State == NanoBotState.WaitingOrders) { if (Fire) { //Ищем ближайшую цель MinDistance = 1000; if (_player.OtherNanoBotsInfo != null) { foreach (NanoBotInfo botEnemy in _player.OtherNanoBotsInfo) { if (botEnemy.PlayerID == 0) { this.Distance = _player.GeomDist(botEnemy.Location, this.Location); //Если вражеский AI достаточно близко, то он пользуется абсолютным приоритетом! if ((botEnemy.NanoBotType == NanoBotType.NanoAI) && (Distance < this.DefenseDistance)) { MinDistance = -1; ShootAt = botEnemy.Location; } if (Distance < MinDistance) { MinDistance = Distance; ShootAt = botEnemy.Location; } } } } //Если противник близко, то стреляем в него. if (MinDistance < this.DefenseDistance) { this.DefendTo(ShootAt, 3); return; } } //Если все NP посещены, то стоим if (this.NPNumber == -10) { this.ForceAutoDestruction(); return; } //Если мы на AZNPoint и нужна дозаправка, то дозаправляемся if (this.Location == this.APoint) { if (this.Stock == 0) { CollectFrom(Location, this.ContainerCapacity / this.CollectTransfertSpeed); return; } } //Если пустые, то находим AZN и идём за ним if (Stock == 0) { this.APoint = _player.GetNearestAZNPoint(this.Location, this.NPoint); MoveTo(_player.Pathfinder.FindPath(this.Location, this.APoint)); return; } else { MoveTo(_player.Pathfinder.FindPath(this.Location, this.NPoint)); return; } } }
public void Action(MyAI _player) { this.MoveTo(_player.AI.Location); }
public void Action(MyAI _player) { if (this.HPNumber == -1) { this.HPoint = _player.GetNextHoshimiPoint(this.Location, ref this.HPNumber); } if (this.HPNumber == -10) { this.HPoint = _player.GetNearestUnfilledHP(this.Location, ref this.HPNumber); } if (HPNumber >= 0) { if (_player.HoshimiPoints[HPNumber].Full == 1) { this.HPoint = _player.GetNearestUnfilledHP(this.Location, ref this.HPNumber); this.StopMoving(); } } if (this.State == NanoBotState.WaitingOrders) { if (this.Location == this.APoint) { if (this.Stock == 0) { //Collect CollectFrom(Location, this.ContainerCapacity / this.CollectTransfertSpeed); } else { //Go Hoshimi point //MoveTo(this.HPoint); MoveTo(_player.Pathfinder.FindPath(this.Location, this.HPoint)); } } if (this.Location == this.HPoint) { foreach (NanoBot bot in _player.NanoBots) { if ((bot is Needle) && (bot.Stock == bot.ContainerCapacity) && (bot.Location == this.Location)) { if (HPNumber >= 0) { _player.HoshimiPoints[HPNumber].Full = 1; this.HPoint = _player.GetNearestUnfilledHP(this.Location, ref this.HPNumber); //Добавить возможность "дозаправки"!!! if (Stock == 0) { this.APoint = _player.GetNearestAZNPoint(this.Location, this.HPoint); //MoveTo(this.APoint); MoveTo(_player.Pathfinder.FindPath(this.Location, this.APoint)); } else { //this.MoveTo(this.HPoint); MoveTo(_player.Pathfinder.FindPath(this.Location, this.HPoint)); } } } } if (Stock == 0) { //return to azn this.APoint = _player.GetNearestAZNPoint(this.Location, this.HPoint); //MoveTo(this.APoint); MoveTo(_player.Pathfinder.FindPath(this.Location, this.APoint)); } else { //transfert TransferTo(Location, this.Stock / this.CollectTransfertSpeed); } } //Добавить возможность "дозаправки"!!! if (Stock == 0) { this.APoint = _player.GetNearestAZNPoint(this.Location, this.HPoint); //this.MoveTo(this.APoint); MoveTo(_player.Pathfinder.FindPath(this.Location, this.APoint)); } else { //this.HPoint = _player.GetNearestUnfilledHP(this.Location, ref this.HPNumber); //this.MoveTo(this.HPoint); MoveTo(_player.Pathfinder.FindPath(this.Location, this.HPoint)); } } }