Example #1
0
        public Command DummyAI()
        {
            //if (!GetComponent<AIVision>().CanSeeTarget(SubObjectTag.PC))
            //{
            //    if (GetComponent<NPCMemory>().RememberPC())
            //    {
            //        return Command.Approach;
            //    }
            //    return Command.Wait;
            //}
            //else
            //{
            //    if (board.GetDistance(gameObject, FindObjects.PC) > meleeRange)
            //    {
            //        return Command.Approach;
            //    }
            //    return Command.Attack;
            //}

            if (GetComponent <AIVision>().CanSeeTarget(SubObjectTag.PC))
            {
                if (board.GetDistance(gameObject, FindObjects.PC) > meleeRange)
                {
                    return(Command.Approach);
                }
                return(Command.Attack);
            }
            return(Command.Wait);
        }
Example #2
0
        private void ShadowWall()
        {
            bool shape;
            bool distance;
            bool darkness;

            if (wallGrid.Count < 1)
            {
                return;
            }

            position = wallGrid.Pop();
            surround = coordinate.SurroundCoord(Surround.Diagonal, position);

            foreach (var grid in surround)
            {
                gridX = grid[0];
                gridY = grid[1];

                // Wall grid casts a rhombus shadow.
                shape = board.IsInsideRange(FOVShape.Rhombus,
                                            rangeWall, position, grid);

                // Shadow makes surrounding grids which are farther away from the
                // source darker.

                //* Source: @.
                //* Wall: #.
                //* Distance: 3.

                //* 3 3 3 3  |  3 4 4 4
                //* 2 2 2 3  |  2 2 # 4
                //* 1 1 2 3  |  1 1 2 4
                //* @ 1 2 3  |  @ 1 2 3

                distance = board.GetDistance(source, grid)
                           > board.GetDistance(source, position);

                // 1) Shadow from the same type of source do not stack. Two walls
                // do not make one grid even darker.
                // 2) When there are multiple dark sources, only the darkest
                // shadow takes effect.
                // 3) For example, if the distance (X) is increased by 2 from one
                // wall grid (#) and 4 from one fog grid ($), the final
                // modification is +4.

                //* # X $
                //* # $ $

                darkness = shape
                    ? (distanceBoard[gridX, gridY]
                       < board.GetDistance(source, grid) + shadowWall)
                    : false;

                if (shape && distance && darkness)
                {
                    distanceBoard[gridX, gridY] += shadowWall;
                    wallGrid.Push(grid);
                }
            }

            ShadowWall();
        }