Example #1
0
 public void Copy(SpawnData other)
 {
     triggerType  = other.triggerType;
     spawnTurn    = other.spawnTurn;
     triggerIndex = other.triggerIndex;
     faction      = other.faction;
     x            = other.x;
     y            = other.y;
     level        = other.level;
     charData     = other.charData;
     for (int i = 0; i < other.inventory.Count; i++)
     {
         inventory.Add(new WeaponTuple()
         {
             item      = other.inventory[i].item,
             droppable = other.inventory[i].droppable
         });
     }
     joiningSquad = other.joiningSquad;
     aggroType    = other.aggroType;
     hasQuotes    = other.hasQuotes;
     quotes.Clear();
     for (int i = 0; i < other.quotes.Count; i++)
     {
         quotes.Add(new FightQuote()
         {
             triggerer = other.quotes[i].triggerer,
             quote     = other.quotes[i].quote,
             activated = other.quotes[i].activated
         });
     }
     talks.Clear();
     for (int i = 0; i < other.talks.Count; i++)
     {
         talks.Add(new FightQuote()
         {
             triggerer = other.talks[i].triggerer,
             quote     = other.talks[i].quote,
             willJoin  = other.talks[i].willJoin,
             activated = other.talks[i].activated
         });
     }
     huntX           = other.huntX;
     huntY           = other.huntY;
     patrolPositions = new List <Position>();
     for (int i = 0; i < other.patrolPositions.Count; i++)
     {
         patrolPositions.Add(new Position()
         {
             x = other.patrolPositions[i].x, y = other.patrolPositions[i].y
         });
     }
 }
Example #2
0
 // Start is called before the first frame update
 void Start()
 {
     gm        = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameManager>();
     enemyList = new List <GameObject>();
     aggroType = GetComponent <AggroType>();
     core      = GameObject.FindGameObjectWithTag("Finish").gameObject;
     if (gameObject.CompareTag("Enemy"))
     {
         agent = GetComponent <NavMeshAgent>();
     }
     if (gameObject.CompareTag("Enemy"))
     {
         currentRoom = gm.rootRoom;
     }
 }
Example #3
0
        public AiScript()
        {
            this.Phrases = new List<string>();

            _lastBeat = DateTime.MinValue;
            _heartbeat = IdleHeartbeat;
            _heartbeatTimer = new Timer(this.Heartbeat, null, -1, -1);

            _rnd = new Random(RandomProvider.Get().Next());

            _state = AiState.Idle;
            _aggroRadius = 500;
            _aggroMaxRadius = 3000;
            _alertDelay = TimeSpan.FromMilliseconds(8000);
            _aggroDelay = TimeSpan.FromMilliseconds(4000);
            _hateTags = new Dictionary<string, string>();
            _loveTags = new Dictionary<string, string>();

            _aggroType = AggroType.Passive;
            _aggroLimit = AggroLimit.One;
        }
Example #4
0
        private static string TransAggroType(AggroType type)
        {
            switch (type)
            {
            case AggroType.Unspecified:
                return("不确定");

            case AggroType.Sight:
                return("视野范围");

            case AggroType.Sound:
                return("声音");

            case AggroType.Proximity:
                return("靠近");

            case AggroType.Boss:
                return("Boss");

            default:
                return(type.ToString());
            }
        }
Example #5
0
    /// <summary>
    /// Ends the character's movement and clears the map of the selection.
    /// </summary>
    public override void EndMovement()
    {
        //Debug.Log("Finished move");
        isMoving = false;
        battleMap.ResetMap();
        currentTile.current = true;

        if (aggroType == AggroType.HUNT && currentTile == huntTile)
        {
            aggroType = AggroType.CHARGE;
            huntTile.SetTerrain(huntTile.alternativeTerrain);
            destroyedTileEvent.Invoke();
        }
        else if (aggroType == AggroType.ESCAPE && currentTile == huntTile)
        {
            escapeEvent.Invoke();
            Escape();
        }
        else
        {
            finishedMovingEvent.Invoke();
        }
    }
Example #6
0
    /// <summary>
    /// Searches for the best tile to move to with the currently equipped weapon.
    /// If no tile can be reached within 1 turn, a good tile is picked instead and the
    /// AI will be able to move towards that tile instead.
    /// </summary>
    /// <param name="weapons"></param>
    /// <param name="tileBest"></param>
    /// <param name="tileGood"></param>
    private void FindBestTile(List <InventoryTuple> weapons, out MapTile tileBest, out MapTile tileGood)
    {
        // Generate map links
        GenerateHitTiles(weapons);

        if (aggroType == AggroType.HUNT && huntTile.interacted)
        {
            aggroType = AggroType.CHARGE;
            Debug.Log("CHARGE!");
        }

        // Skip move if guarding type of enemy
        if (aggroType == AggroType.GUARD || aggroType == AggroType.BOSS)
        {
            if (currentTile.attackable)
            {
                currentMode.value = (weapons[0].itemCategory == ItemCategory.WEAPON) ? ActionMode.ATTACK : ActionMode.HEAL;
                //currentMode.value = ActionMode.MOVE;
                tileBest = currentTile;
                //tileBest = null;
                tileGood = null;
            }
            else
            {
                tileBest = null;
                tileGood = null;
                //tileGood = currentTile;
                currentMode.value = ActionMode.NONE;
            }
            return;
        }

        BFS();

        int     moveSpeed = GetMoveSpeed();
        MapTile bestTile  = null;        // Reachable this turn
        MapTile goodTile  = null;        // Reachable in multiple turns

        //Hunting or Escaping AI
        if (aggroType == AggroType.HUNT || aggroType == AggroType.ESCAPE)
        {
            tileBest = huntTile;
            tileGood = null;
            while (tileBest != null && (tileBest.distance > moveSpeed || !tileBest.selectable))
            {
                tileBest = tileBest.parent;
            }
            if (tileBest != null)
            {
                tileBest.PrintPos();
                currentMode.value = ActionMode.MOVE;
                return;
            }
        }

        // Go through all tiles and find the best one to move to or towards
        for (int i = 0; i < battleMap.tiles.Length; i++)
        {
            MapTile tempTile = battleMap.tiles[i];
            if ((!tempTile.attackable && !tempTile.supportable) || !tempTile.selectable)
            {
                continue;
            }

            tempTile.target = true;
            if (tempTile.distance <= moveSpeed)
            {
                if (IsBetterTile(bestTile, tempTile))
                {
                    bestTile = tempTile;
                }
            }
            else
            {
                if (IsBetterTile(goodTile, tempTile))
                {
                    goodTile = tempTile;
                }
            }
        }

        if (bestTile)
        {
            // Found a best tile to move to
            bestTile.current  = true;
            currentMode.value = (weapons[0].itemCategory == ItemCategory.WEAPON) ? ActionMode.ATTACK : ActionMode.HEAL;
            tileBest          = bestTile;
            tileGood          = null;
            if (aggroType == AggroType.WAIT)
            {
                aggroType = AggroType.CHARGE;
            }
        }
        else if (goodTile && aggroType != AggroType.CHARGE && aggroType != AggroType.PATROL)
        {
            //Have no weapons that can be used
            currentMode.value = ActionMode.NONE;
            tileBest          = null;
            tileGood          = null;
        }
        else if (aggroType == AggroType.PATROL)
        {
            tileBest = null;
            tileGood = patrolTiles[patrolIndex];
            while (tileGood != null && (tileGood.distance > moveSpeed || !tileGood.selectable))
            {
                tileGood = tileGood.parent;
            }
            if (tileGood != null)
            {
                tileGood.PrintPos();
                currentMode.value = ActionMode.MOVE;
                if (tileGood == patrolTiles[patrolIndex])
                {
                    patrolIndex = OPMath.FullLoop(0, patrolTiles.Count, patrolIndex + 1);
                }
                return;
            }
            else
            {
                currentMode.value = ActionMode.NONE;
                tileGood          = null;
                return;
            }
        }
        else
        {
            //The finds the tile which takes the character towards the good tile
            if (goodTile != null)
            {
                while (goodTile.distance > moveSpeed || !goodTile.IsEmpty(this))
                {
                    goodTile = goodTile.parent;
                }
                goodTile.current = true;
            }

            currentMode.value = ActionMode.MOVE;
            tileBest          = null;
            tileGood          = goodTile;
        }
    }
Example #7
0
		/// <summary>
		/// The way the AI decides whether to go into Alert/Aggro.
		/// </summary>
		/// <param name="type"></param>
		protected void SetAggroType(AggroType type)
		{
			//_aggroType = type;
			Log.Warning("{0}: SetAggroType is obsolete, use 'Doubts' and 'HatesBattleStance' instead.", this.GetType().Name);
		}
Example #8
0
 /// <summary>
 /// The way the AI decides whether to go into Alert/Aggro.
 /// </summary>
 /// <param name="type"></param>
 protected void SetAggroType(AggroType type)
 {
     //_aggroType = type;
     Log.Warning("{0}: SetAggroType is obsolete, use 'Doubts' and 'HatesBattleStance' instead.", this.GetType().Name);
 }
Example #9
0
 /// <summary>
 /// The way the AI decides whether to go into Alert/Aggro.
 /// </summary>
 /// <param name="time"></param>
 protected void SetAggroType(AggroType type)
 {
     _aggroType = type;
 }