예제 #1
0
파일: Combat.cs 프로젝트: Wolfie13/RTSAI
	public override ActionResult actionTick (Person person)
	{
		if (person.Skills.Contains(Skill.Rifleman))
		{
			List<Person> others = new List<Person>();
			for(IVec2 offset = new IVec2(-5,-5); offset.x < 6;++offset.x)
			{
				for(offset.y = -5; offset.y < 6;++offset.y)
				{
					if(offset.magnitude() <= 5)
					{
						others.AddRange(Map.CurrentMap.GetPeopleAt(person.currentMapPos + offset));
					}
				}
			}
			Person other = null;
			foreach (var item in others)
			{
				if(item.teamID != person.teamID)
				{
					other = item;
					break;
				}
			}
			if(other)
			{
				if(other.Skills.Contains(Skill.Rifleman) && UnityEngine.Random.Range(0,100) < (100.0f/3f * 2f))
				{
					Map.CurrentMap.KillPerson(person);
				}
				else
				{
					Map.CurrentMap.KillPerson(other);
					person.SetBusy(1);
				}
			}
		}
		return ActionResult.FAIL;
	}
예제 #2
0
파일: AStar.cs 프로젝트: Wolfie13/RTSAI
	private List<AStarNodes> GetNextPositions(AStarNodes CurrentNode, IVec2 MapPosEnd)
    {
        List<AStarNodes> NextPositions = new List<AStarNodes>();

        for (IVec2 offset = new IVec2(-1, -1); offset.x <= 1; ++offset.x)
        {

            for (offset.y = -1; offset.y <= 1; ++offset.y)
            {
                IVec2 newPos = CurrentNode.NodeInfo.MapPos + offset;

                if(newPos.x <0 || 
                    newPos.x > Map.CurrentMap.sizeX)
                     break;

                if (newPos.y < 0 || newPos == CurrentNode.NodeInfo.MapPos ||
                    newPos.y > Map.CurrentMap.sizeY ||
                    offset == new IVec2(0,0))
                    continue;

               
                if(Map.Trees.Contains(Map.CurrentMap.getTile(newPos.x, newPos.y)) ||
                   Map.Terrain.Contains(Map.CurrentMap.getTile(newPos.x, newPos.y)))
                {
                    AStarNodes newNode = new AStarNodes();

                    newNode.DistanceGone = CurrentNode.DistanceGone + offset.magnitude();
                    //newNode.NodeInfo.MapSymbol = PathFinder.CurrentMap.getTile(newPos.x, newPos.y)
                    newNode.NodeInfo = new Node();
                    newNode.NodeInfo.MapPos = newPos;
                    newNode.NodeInfo.PrevNode = CurrentNode.NodeInfo;
					newNode.Distance2Go = GetDirectDistance2End(newPos, MapPosEnd);

                    NextPositions.Add(newNode);
                }

            }

        }

            return NextPositions;

    }