Beispiel #1
0
    public void SendBuilderBuild(int builderNO, int builderLevel, IObstacleInfo targetInfo, IMapData mapData)
    {
        GameObject builder = null;

        if (this.m_Builders.ContainsKey(builderNO))
        {
            builder = this.m_Builders[builderNO];
            builder.SetActive(true);
        }
        else
        {
            builder = this.GenerateBuilder(builderNO, builderLevel);
            this.m_Builders.Add(builderNO, builder);
        }


        TilePosition buildPoint = BorderPointHelper.FindValidInflateOneBorderPoint(targetInfo);

        builder.transform.position = PositionConvertor.GetWorldPositionFromActorTileIndex(buildPoint);

        BuilderAI builderAI = builder.GetComponent <BuilderAI>();

        builderAI.MapData   = mapData;
        builderAI.BuilderNO = builderNO;
        builderAI.Build(targetInfo, buildPoint);
    }
Beispiel #2
0
    public void FindTargetObject(IBuildingInfo buildingInfo, TilePosition startPosition)
    {
        List <IBuildingInfo> buildings = this.SceneHelper.GetAllBuildings();

        int           index = Random.Range(0, buildings.Count);
        IBuildingInfo targetBuildingInfo = buildings[index];

        if (buildingInfo != null)
        {
            while (buildingInfo == targetBuildingInfo)
            {
                index = Random.Range(0, buildings.Count);
                targetBuildingInfo = buildings[index];
            }
        }

        TilePosition targetPoint = BorderPointHelper.FindValidInflateOneBorderPoint(targetBuildingInfo);

        if (startPosition != null)
        {
            this.transform.position = PositionConvertor.GetWorldPositionFromActorTileIndex(startPosition);
        }
        VillagerWalkState walkState = new VillagerWalkState(this.MapData, targetPoint, this, targetBuildingInfo);

        this.ChangeState(walkState);
    }
Beispiel #3
0
 protected override bool OnTargetMove()
 {
     this.m_TargetObjectPosition = this.m_TargetInfo.ActorPosition;
     this.m_TargetPosition       = BorderPointHelper.FindValidInflateOneBorderPoint(this.m_TargetInfo);
     this.FindPath();
     return(true);
 }
Beispiel #4
0
    public void RunAway(List <IBuildingInfo> builderHuts)
    {
        IBuildingInfo targetInfo  = builderHuts[this.BuilderNO];
        TilePosition  targetPoint = BorderPointHelper.FindValidInflateOneBorderPoint(targetInfo);

        ActorRunAwayState runAwayState = new ActorRunAwayState(this.MapData, targetPoint, this);

        this.ChangeState(runAwayState);
    }
Beispiel #5
0
    public void FinishBuild()
    {
        BuildingLogicData logicData = LogicController.Instance.GetBuildingObject(
            new BuildingIdentity(BuildingType.BuilderHut, this.BuilderNO));
        TilePosition targetPosition = BorderPointHelper.FindValidInflateOneBorderPoint(logicData);

        BuilderReturnState returnState = new BuilderReturnState(this.MapData, targetPosition, this, logicData);

        this.ChangeState(returnState);
    }
Beispiel #6
0
    public void SendMercenaryToCamp(MercenaryType mercenaryType, IBuildingInfo campInfo, IBuildingInfo factoryInfo)
    {
        GameObject   mercenary    = this.GenerateMercenary(mercenaryType);
        TilePosition initialPoint = BorderPointHelper.FindValidInflateOneBorderPoint(factoryInfo);

        mercenary.transform.position = PositionConvertor.GetWorldPositionFromActorTileIndex(initialPoint);

        ArmyAI ai = mercenary.GetComponent <ArmyAI>();

        ai.SendArmyToCamp(campInfo);
    }
Beispiel #7
0
    public void SendArmyToCamp(ArmyType armyType, int level, IBuildingInfo campInfo, IBuildingInfo factoryInfo)
    {
        GameObject   army         = this.GenerateArmy(armyType, level);
        TilePosition initialPoint = BorderPointHelper.FindValidInflateOneBorderPoint(factoryInfo);

        army.transform.position = PositionConvertor.GetWorldPositionFromActorTileIndex(initialPoint);

        ArmyAI ai = army.GetComponent <ArmyAI>();

        ai.SendArmyToCamp(campInfo);
    }
Beispiel #8
0
 protected override bool OnTargetMove()
 {
     this.m_TargetPosition = this.m_TargetInfo.ActorPosition + this.m_Offset;
     while (!this.m_TargetPosition.IsValidActorTilePosition())
     {
         this.m_TargetPosition = BorderPointHelper.FindValidInflateOneBorderPoint(this.m_TargetInfo);
         this.m_Offset         = this.m_TargetPosition - this.m_TargetInfo.ActorPosition;
     }
     this.FindPath();
     return(true);
 }
    protected override void OnTimeUp()
    {
        TilePosition newBuildPosition = BorderPointHelper.FindValidInflateOneBorderPoint(this.m_TargetInfo);

        if (newBuildPosition.Equals(this.m_BuildPosition))
        {
            this.Initial();
        }
        else
        {
            BuilderBuildHoverState hoverState = new BuilderBuildHoverState(this.m_TargetInfo, this.m_MapData, newBuildPosition, this.m_AIBehavior);            //this.m_TargetInfo, newBuildPosition, this.m_AIBehavior);
            this.m_AIBehavior.ChangeState(hoverState);
        }
    }
Beispiel #10
0
    public void RunAway(HashSet <BuildingType> disappearBuildings)
    {
        if (this.m_CurrentState is VillagerDisappearState)
        {
            GameObject.Destroy(this.gameObject);
        }
        else
        {
            List <IBuildingInfo> buildings = this.SceneHelper.GetBuildingsOfTypes(disappearBuildings);
            int index = Random.Range(0, buildings.Count);

            IBuildingInfo disappearBuilding = buildings[index];
            TilePosition  targetPosition    = BorderPointHelper.FindValidInflateOneBorderPoint(disappearBuilding);

            ActorRunAwayState runAwayState = new ActorRunAwayState(this.MapData, targetPosition, this);
            this.ChangeState(runAwayState);
        }
    }