コード例 #1
0
        protected override bool ProducerHasRequirements(BuildableInfo buildable)
        {
            var producers = Actor.World.ActorsWithTrait <Common.Traits.Production>().Where(x => !x.Trait.IsTraitDisabled && x.Actor.Owner == Actor.Owner).Select(x => x.Actor);

            return(producers.Any(producer =>
            {
                if (!producer.Info.TraitInfos <ProvidesPrerequisiteInfo>().Any(providesPrerequisite => buildable.Prerequisites.Contains(providesPrerequisite.Prerequisite)))
                {
                    return false;
                }

                var advancedBuildable = buildable as AdvancedBuildableInfo;

                if (advancedBuildable == null)
                {
                    return true;
                }

                if (advancedBuildable.Level == -1)
                {
                    return false;
                }

                return advancedBuildable.Level == 0 || advancedBuildable.Level <= producer.Trait <Researchable>().Level;
            }));
        }
コード例 #2
0
        public void Produce(string actorType, string factionVariant = null, string productionType = null)
        {
            ActorInfo actorInfo;

            if (!Self.World.Map.Rules.Actors.TryGetValue(actorType, out actorInfo))
            {
                throw new LuaException("Unknown actor type '{0}'".F(actorType));
            }

            Self.QueueActivity(new WaitFor(() =>
            {
                // Go through all available traits and see which one successfully produces
                foreach (var p in productionTraits)
                {
                    if (!string.IsNullOrEmpty(productionType) && !p.Info.Produces.Contains(productionType))
                    {
                        continue;
                    }

                    var inits = new TypeDictionary
                    {
                        new OwnerInit(Self.Owner),
                        new FactionInit(factionVariant ?? BuildableInfo.GetInitialFaction(actorInfo, p.Faction))
                    };

                    if (p.Produce(Self, actorInfo, productionType, inits))
                    {
                        return(true);
                    }
                }

                // We didn't produce anything, wait until we do
                return(false);
            }));
        }
コード例 #3
0
ファイル: BuildManager.cs プロジェクト: hanhonglei/Yotta
    static public bool CheckBuildPoint(Vector3 pointer)
    {
        BuildableInfo buildableInfo = new BuildableInfo();

        return(false);
        //LayerMask mask = 1 << LayerManager.LayerPlatform ();
    }
コード例 #4
0
        protected override bool ProducerHasRequirements(ActorInfo prod, BuildableInfo buildable)
        {
            var producers = this.Actor.World.ActorsWithTrait <Production>()
                            .Where(x => !x.Trait.IsTraitDisabled && x.Actor.Owner == this.Actor.Owner)
                            .Select(x => x.Actor);

            return(producers.Any(
                       producer =>
            {
                if (!producer.Info.TraitInfos <ProvidesPrerequisiteInfo>()
                    .Any(providesPrerequisite => buildable.Prerequisites.Contains(providesPrerequisite.Prerequisite)))
                {
                    return false;
                }

                if (buildable is not TechLevelBuildableInfo)
                {
                    return true;
                }

                var researchable = producer.TraitOrDefault <Researchable>();

                return researchable.IsResearched(TechLevelBuildableInfo.Prefix + prod.Name);
            }
                       ));
        }
コード例 #5
0
ファイル: UI.cs プロジェクト: JOGHURTaka/Unity-War_of_Lords
    //called whevenever the build list is called up
    //compute the number of tower that can be build in this build pointer
    //store the tower that can be build in an array of number that reference to the towerlist
    //this is so these dont need to be calculated in every frame in OnGUI()
    void UpdateBuildList()
    {
        //get the current buildinfo in buildmanager
        BuildableInfo currentBuildInfo = BuildManager.GetBuildInfo();

        //get the current tower list in buildmanager
        UnitTower[] towerList = BuildManager.GetTowerList();

        //construct a temporary interger array the length of the buildinfo
        int[] tempBuildList = new int[towerList.Length];
        //for(int i=0; i<currentBuildList.Length; i++) tempBuildList[i]=-1;

        //scan through the towerlist, if the tower matched the build type,
        //put the tower ID in the towerlist into the interger array
        int count = 0;          //a number to record how many towers that can be build

        for (int i = 0; i < towerList.Length; i++)
        {
            UnitTower tower = towerList[i];

            if (currentBuildInfo.specialBuildableID != null && currentBuildInfo.specialBuildableID.Length > 0)
            {
                foreach (int specialBuildableID in currentBuildInfo.specialBuildableID)
                {
                    if (specialBuildableID == tower.specialID)
                    {
                        count += 1;
                        break;
                    }
                }
            }
            else
            {
                if (tower.specialID < 0)
                {
                    //check if this type of tower can be build on this platform
                    foreach (_TowerType type in currentBuildInfo.buildableType)
                    {
                        if (tower.type == type && tower.specialID < 0)
                        {
                            tempBuildList[count] = i;
                            count += 1;
                            break;
                        }
                    }
                }
            }
        }

        //for as long as the number that can be build, copy from the temp buildList to the real buildList
        currentBuildList = new int[count];
        for (int i = 0; i < currentBuildList.Length; i++)
        {
            currentBuildList[i] = tempBuildList[i];
        }
    }
コード例 #6
0
        public override int GetBuildTime(ActorInfo unit, BuildableInfo bi)
        {
            // Workaround to make above Tick receive a 0 for the production time.
            if (expectFakeProductionItemRequest)
            {
                expectFakeProductionItemRequest = false;
                return(0);
            }

            return(base.GetBuildTime(unit, bi));
        }
コード例 #7
0
ファイル: UI.cs プロジェクト: JOGHURTaka/Unity-War_of_Lords
    void BuildMenuPie()
    {
        BuildableInfo currentBuildInfo = BuildManager.GetBuildInfo();

        //calculate the position in which the build list ui will be appear at
        Vector3 screenPos = Camera.main.WorldToScreenPoint(currentBuildInfo.position);

        int width  = 50;
        int height = 50;

        Vector2[] piePos = GetPieMenuPos(currentBuildList.Length, screenPos, (int)1.414f * (width + height) / 2);

        scatteredRectList = new Rect[currentBuildList.Length + 1];

        //show up the build buttons, scrolling through currentBuildList initiated whevenever the menu is first brought up
        UnitTower[] towerList = BuildManager.GetTowerList();

        for (int num = 0; num < currentBuildList.Length; num++)
        {
            int ID = currentBuildList[num];

            if (ID >= 0)
            {
                UnitTower tower = towerList[ID];
                Vector2   point = piePos[num];

                scatteredRectList[num] = new Rect(point.x - width / 2, Screen.height - point.y - height * 0.75f, width, height);

                GUIContent guiContent = new GUIContent(tower.icon, ID.ToString());
                if (GUI.Button(scatteredRectList[num], guiContent))
                {
                    //if building was successful, break the loop can close the panel
                    if (BuildButtonPressed(tower))
                    {
                        return;
                    }
                }
            }
        }

        //clear buildmode button
        scatteredRectList[currentBuildList.Length] = new Rect(screenPos.x - width / 2, Screen.height - screenPos.y + height * 0.5f, width, height);

        if (GUI.Button(scatteredRectList[currentBuildList.Length], "X"))
        {
            buildMenu = false;
            BuildManager.ClearBuildPoint();
            ClearBuildListRect();
        }
    }
コード例 #8
0
        public override void Activate(Actor self, Order order, SupportPowerManager manager)
        {
            base.Activate(self, order, manager);

            var info      = Info as ProduceActorPowerCAInfo;
            var producers = self.World.ActorsWithTrait <Production>()
                            .Where(x => x.Actor.Owner == self.Owner &&
                                   !x.Trait.IsTraitDisabled &&
                                   x.Trait.Info.Produces.Contains(info.Type))
                            .OrderByDescending(x => x.Actor.Exits())
                            .ThenByDescending(x => x.Actor.ActorID);

            // TODO: The power should not reset if the production fails.
            // Fixing this will require a larger rework of the support power code
            var activated = false;

            foreach (var p in producers)
            {
                foreach (var name in info.Actors)
                {
                    var ai    = self.World.Map.Rules.Actors[name];
                    var inits = new TypeDictionary
                    {
                        new OwnerInit(self.Owner),
                        new FactionInit(BuildableInfo.GetInitialFaction(ai, faction))
                    };

                    activated |= p.Trait.Produce(p.Actor, ai, info.Type, inits);
                }

                if (activated)
                {
                    break;
                }
            }

            if (activated)
            {
                Game.Sound.PlayNotification(self.World.Map.Rules, manager.Self.Owner, "Speech", info.ReadyAudio, self.Owner.Faction.InternalName);
            }
            else
            {
                Game.Sound.PlayNotification(self.World.Map.Rules, manager.Self.Owner, "Speech", info.BlockedAudio, self.Owner.Faction.InternalName);
            }
        }
        public void Produce(string actorType, string factionVariant = null, string productionType = null)
        {
            ActorInfo actorInfo;

            if (!Self.World.Map.Rules.Actors.TryGetValue(actorType, out actorInfo))
            {
                throw new LuaException("Unknown actor type '{0}'".F(actorType));
            }

            var faction = factionVariant ?? BuildableInfo.GetInitialFaction(actorInfo, p.Faction);
            var inits   = new TypeDictionary
            {
                new OwnerInit(Self.Owner),
                new FactionInit(faction)
            };

            Self.QueueActivity(new WaitFor(() => p.Produce(Self, actorInfo, productionType, inits)));
        }
コード例 #10
0
        public void UnitProducedByOther(Actor self, Actor producer, Actor produced, string productionType, TypeDictionary init)
        {
            if (IsTraitDisabled)
            {
                return;
            }

            // No recursive cloning!
            if (producer.Owner != self.Owner || productionType == Info.ProductionType)
            {
                return;
            }

            var ci = produced.Info.TraitInfoOrDefault <CloneableInfo>();

            if (ci == null || !Info.CloneableTypes.Overlaps(ci.Types))
            {
                return;
            }

            var factionInit = init.GetOrDefault <FactionInit>();

            // Stop as soon as one production trait successfully produced
            foreach (var p in productionTraits)
            {
                if (!string.IsNullOrEmpty(Info.ProductionType) && !p.Info.Produces.Contains(Info.ProductionType))
                {
                    continue;
                }

                var inits = new TypeDictionary
                {
                    new OwnerInit(self.Owner),
                    factionInit ?? new FactionInit(BuildableInfo.GetInitialFaction(produced.Info, p.Faction))
                };

                if (p.Produce(self, produced.Info, Info.ProductionType, inits, 0))
                {
                    return;
                }
            }
        }
コード例 #11
0
        protected virtual bool ProducerHasRequirements(ActorInfo prod, BuildableInfo buildable)
        {
            if (!this.Actor.Info.TraitInfos <ProvidesPrerequisiteInfo>()
                .Any(providesPrerequisite => buildable.Prerequisites.Contains(providesPrerequisite.Prerequisite)))
            {
                return(false);
            }

            if (buildable is not TechLevelBuildableInfo advancedBuildable)
            {
                return(true);
            }

            if (advancedBuildable.Level == -1)
            {
                return(false);
            }

            var researchable = this.actor.TraitOrDefault <Researchable>();

            return(researchable.IsResearched(TechLevelBuildableInfo.Prefix + prod.Name));
        }
コード例 #12
0
ファイル: ClonesProducedUnits.cs プロジェクト: DoGyAUT/OpenRA
        public void UnitProducedByOther(Actor self, Actor producer, Actor produced, string productionType)
        {
            // No recursive cloning!
            if (producer.Owner != self.Owner || producer.Info.HasTraitInfo <ClonesProducedUnitsInfo>())
            {
                return;
            }

            var ci = produced.Info.TraitInfoOrDefault <CloneableInfo>();

            if (ci == null || !info.CloneableTypes.Overlaps(ci.Types))
            {
                return;
            }

            var inits = new TypeDictionary
            {
                new OwnerInit(self.Owner),
                new FactionInit(BuildableInfo.GetInitialFaction(produced.Info, faction))
            };

            production.Produce(self, produced.Info, productionType, inits);
        }
コード例 #13
0
        protected virtual bool ProducerHasRequirements(BuildableInfo buildable)
        {
            if (!Actor.Info.TraitInfos <ProvidesPrerequisiteInfo>().Any(providesPrerequisite => buildable.Prerequisites.Contains(providesPrerequisite.Prerequisite)))
            {
                return(false);
            }

            var advancedBuildable = buildable as AdvancedBuildableInfo;

            if (advancedBuildable == null)
            {
                return(true);
            }

            if (advancedBuildable.Level == -1)
            {
                return(false);
            }

            var researchable = actor.TraitOrDefault <Researchable>();

            return(advancedBuildable.Level == 0 || (researchable != null && advancedBuildable.Level <= researchable.Level));
        }
コード例 #14
0
ファイル: BuildManager.cs プロジェクト: wdj294/tdtk
    public static bool CheckBuildPoint(Vector3 pointer)
    {
        //if(currentBuildInfo!=null) return false;

        BuildableInfo buildableInfo=new BuildableInfo();

        //layerMask for platform only
        LayerMask maskPlatform=1<<LayerManager.LayerPlatform();
        //layerMask for detect all collider within buildPoint
        LayerMask maskAll=1<<LayerManager.LayerPlatform();
        if(buildManager.terrainColliderLayer>=0) maskAll|=1<<buildManager.terrainColliderLayer;

        Ray ray = Camera.main.ScreenPointToRay(pointer);
        RaycastHit hit;
        if(Physics.Raycast(ray, out hit, Mathf.Infinity, maskPlatform)){

            for(int i=0; i<buildManager.buildPlatforms.Length; i++){

                Transform basePlane=buildManager.buildPlatforms[i].thisT;
                if(hit.transform==basePlane){

                    //calculating the build center point base on the input position

                    //check if the row count is odd or even number
                    float remainderX=UnitUtility.GetWorldScale(basePlane).x*10/_gridSize%2;
                    float remainderZ=UnitUtility.GetWorldScale(basePlane).z*10/_gridSize%2;

                    //get the rotation offset of the plane
                    Quaternion rot=Quaternion.LookRotation(hit.point-basePlane.position);

                    //get the x and z distance from the centre of the plane in the baseplane orientation
                    //from this point on all x and z will be in reference to the basePlane orientation
                    float dist=Vector3.Distance(hit.point, basePlane.position);
                    float distX=Mathf.Sin((rot.eulerAngles.y-basePlane.rotation.eulerAngles.y)*Mathf.Deg2Rad)*dist;
                    float distZ=Mathf.Cos((rot.eulerAngles.y-basePlane.rotation.eulerAngles.y)*Mathf.Deg2Rad)*dist;

                    //get the sign (1/-1) of the x and y direction
                    float signX=distX/Mathf.Abs(distX);
                    float signZ=distZ/Mathf.Abs(distZ);

                    //calculate the tile number selected in z and z direction
                    float numX=Mathf.Round((distX+(remainderX-1)*(signX*_gridSize/2))/_gridSize);
                    float numZ=Mathf.Round((distZ+(remainderZ-1)*(signZ*_gridSize/2))/_gridSize);

                    //calculate offset in x-axis,
                    float offsetX=-(remainderX-1)*signX*_gridSize/2;
                    float offsetZ=-(remainderZ-1)*signZ*_gridSize/2;

                    //get the pos and apply the offset
                    Vector3 p=basePlane.TransformDirection(new Vector3(numX, 0, numZ)*_gridSize);
                    p+=basePlane.TransformDirection(new Vector3(offsetX, 0, offsetZ));

                    //set the position;
                    Vector3 pos=p+basePlane.position;

                    //check if the position is blocked, by any other obstabcle other than the baseplane itself
                    Collider[] cols=Physics.OverlapSphere(pos, _gridSize/2*0.9f, ~maskAll);
                    if(cols.Length>0){
                        //Debug.Log("something's in the way "+cols[0]);
                        return false;
                    }
                    else{
                        //confirm that we can build here
                        buildableInfo.buildable=true;
                        buildableInfo.position=pos;
                        buildableInfo.platform=buildManager.buildPlatforms[i];
                    }

                    //check if the platform is walkable, if so, check if building on the point wont block all possible path
                    if(buildManager.buildPlatforms[i].IsWalkable()){
                        //return true is the platform is not block
                        if(buildManager.buildPlatforms[i].CheckForBlock(pos)){
                            Debug.Log("all path is blocked");
                            return false;
                        }
                    }

                    buildableInfo.buildableType=buildManager.buildPlatforms[i].buildableType;
                    buildableInfo.specialBuildableID=buildManager.buildPlatforms[i].specialBuildableID;

                    break;
                }

            }

        }
        else return false;

        currentBuildInfo=buildableInfo;

        if(buildManager.enableTileIndicator){
            indicator.active=true;
            indicator.transform.position=currentBuildInfo.position;
            indicator.transform.rotation=currentBuildInfo.platform.thisT.rotation;
        }

        return true;
    }
コード例 #15
0
ファイル: UI.cs プロジェクト: JOGHURTaka/Unity-War_of_Lords
    void BuildMenuBox()
    {
        BuildableInfo currentBuildInfo = BuildManager.GetBuildInfo();

        //calculate the position in which the build list ui will be appear at
        Vector3 screenPos = Camera.main.WorldToScreenPoint(currentBuildInfo.position);

        int width  = 50;
        int height = 50;

        int x = (int)screenPos.x - width;

        x = Mathf.Clamp(x, 0, Screen.width - width * 2);

        int menuLength = ((int)Mathf.Floor((currentBuildList.Length + 2) / 2)) * (height + 3);
        int y          = Screen.height - (int)screenPos.y; //invert the height

        y -= menuLength / 2 - 3;
        y  = Mathf.Clamp(y, 29, Screen.height - menuLength - (int)bottomPanelRect.height);

        //calculate the buildlist rect
        buildListRect = new Rect(x - 3, y - 3, width * 2 + 6 + 3, menuLength + 4);
        for (int i = 0; i < 3; i++)
        {
            GUI.Box(buildListRect, "");
        }

        //show up the build buttons, scrolling through currentBuildList initiated whevenever the menu is first brought up
        UnitTower[] towerList = BuildManager.GetTowerList();

        for (int num = 0; num < currentBuildList.Length; num++)
        {
            int ID = currentBuildList[num];

            if (ID >= 0)
            {
                UnitTower tower = towerList[ID];

                GUIContent guiContent = new GUIContent(tower.icon, ID.ToString());
                if (GUI.Button(new Rect(x, y, width, height), guiContent))
                {
                    //if building was successful, break the loop can close the panel
                    if (BuildButtonPressed(tower))
                    {
                        return;
                    }
                }

                if (num % 2 == 1)
                {
                    x -= width + 3;
                    y += height + 3;
                }
                else
                {
                    x += width + 3;
                }
            }
        }

        //clear buildmode button
        if (GUI.Button(new Rect(x, y, width, height), "X"))
        {
            buildMenu = false;
            BuildManager.ClearBuildPoint();
            ClearBuildListRect();
        }
    }
コード例 #16
0
ファイル: TechTree.cs プロジェクト: nevelis/OpenRA
 public Watcher(string key, BuildableInfo info, ITechTreeElement watcher)
 {
     this.key = key;
     this.prerequisites = info.Prerequisites;
     this.watcher = watcher;
     this.hasPrerequisites = false;
     this.buildLimit = info.BuildLimit;
 }
コード例 #17
0
 static public void ClearBuildPoint()
 {
     currentBuildInfo = null;
     ClearIndicator();
 }
コード例 #18
0
    static public bool CheckBuildPoint(Vector3 pointer)
    {
        //if(currentBuildInfo!=null) return false;

        BuildableInfo buildableInfo = new BuildableInfo();

        //layerMask for platform only
        LayerMask maskPlatform = 1 << LayerManager.LayerPlatform();
        //layerMask for detect all collider within buildPoint
        LayerMask maskAll = 1 << LayerManager.LayerPlatform();

        if (buildManager.terrainColliderLayer >= 0)
        {
            maskAll |= 1 << buildManager.terrainColliderLayer;
        }

        Ray        ray = Camera.main.ScreenPointToRay(pointer);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, Mathf.Infinity, maskPlatform))
        {
            for (int i = 0; i < buildManager.buildPlatforms.Length; i++)
            {
                Transform basePlane = buildManager.buildPlatforms[i].thisT;
                if (hit.transform == basePlane)
                {
                    //calculating the build center point base on the input position

                    //check if the row count is odd or even number
                    float remainderX = UnitUtility.GetWorldScale(basePlane).x *10 / _gridSize % 2;
                    float remainderZ = UnitUtility.GetWorldScale(basePlane).z *10 / _gridSize % 2;

                    //get the rotation offset of the plane
                    Quaternion rot = Quaternion.LookRotation(hit.point - basePlane.position);

                    //get the x and z distance from the centre of the plane in the baseplane orientation
                    //from this point on all x and z will be in reference to the basePlane orientation
                    float dist  = Vector3.Distance(hit.point, basePlane.position);
                    float distX = Mathf.Sin((rot.eulerAngles.y - basePlane.rotation.eulerAngles.y) * Mathf.Deg2Rad) * dist;
                    float distZ = Mathf.Cos((rot.eulerAngles.y - basePlane.rotation.eulerAngles.y) * Mathf.Deg2Rad) * dist;

                    //get the sign (1/-1) of the x and y direction
                    float signX = distX / Mathf.Abs(distX);
                    float signZ = distZ / Mathf.Abs(distZ);

                    //calculate the tile number selected in z and z direction
                    float numX = Mathf.Round((distX + (remainderX - 1) * (signX * _gridSize / 2)) / _gridSize);
                    float numZ = Mathf.Round((distZ + (remainderZ - 1) * (signZ * _gridSize / 2)) / _gridSize);

                    //calculate offset in x-axis,
                    float offsetX = -(remainderX - 1) * signX * _gridSize / 2;
                    float offsetZ = -(remainderZ - 1) * signZ * _gridSize / 2;

                    //get the pos and apply the offset
                    Vector3 p = basePlane.TransformDirection(new Vector3(numX, 0, numZ) * _gridSize);
                    p += basePlane.TransformDirection(new Vector3(offsetX, 0, offsetZ));

                    //set the position;
                    Vector3 pos = p + basePlane.position;

                    //check if the position is blocked, by any other obstabcle other than the baseplane itself
                    Collider[] cols = Physics.OverlapSphere(pos, _gridSize / 2 * 0.9f, ~maskAll);
                    if (cols.Length > 0)
                    {
                        //Debug.Log("something's in the way "+cols[0]);
                        return(false);
                    }
                    else
                    {
                        //confirm that we can build here
                        buildableInfo.buildable = true;
                        buildableInfo.position  = pos;
                        buildableInfo.platform  = buildManager.buildPlatforms[i];
                    }

                    buildableInfo.buildableType      = buildManager.buildPlatforms[i].buildableType;
                    buildableInfo.specialBuildableID = buildManager.buildPlatforms[i].specialBuildableID;

                    break;
                }
            }
        }
        else
        {
            return(false);
        }

        currentBuildInfo = buildableInfo;

        if (buildManager.enableTileIndicator)
        {
            indicator.active             = true;
            indicator.transform.position = currentBuildInfo.position;
            indicator.transform.rotation = currentBuildInfo.platform.thisT.rotation;
        }

        return(true);
    }
コード例 #19
0
    public static _TileStatus CheckBuildPoint(Vector3 pointer, int footprint)
    {
        footprint = -1;
        //if(currentBuildInfo!=null) return false;

        _TileStatus   status        = _TileStatus.Available;
        BuildableInfo buildableInfo = new BuildableInfo();

        //layerMask for platform only
        LayerMask maskPlatform = 1 << LayerManager.LayerPlatform();
        //layerMask for detect all collider within buildPoint
        LayerMask maskAll      = 1 << LayerManager.LayerPlatform();
        int       terrainLayer = LayerManager.LayerTerrain();

        if (terrainLayer >= 0)
        {
            maskAll |= 1 << terrainLayer;
        }

        Ray        ray = Camera.main.ScreenPointToRay(pointer);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, Mathf.Infinity, maskPlatform))
        {
            for (int i = 0; i < buildManager.buildPlatforms.Length; i++)
            {
                Transform basePlane = buildManager.platforms[i];

                if (hit.transform == basePlane)
                {
                    //calculating the build center point base on the input position
                    Vector3 pos = GetTilePos(basePlane, hit.point);

                    //check if the position is blocked, by any other obstabcle other than the baseplane itself
                    Collider[] cols = Physics.OverlapSphere(pos, _gridSize / 2 * 0.9f + footprint * _gridSize, ~maskAll);
                    if (cols.Length > 0)
                    {
                        //Debug.Log("something's in the way "+cols[0]);
                        return(_TileStatus.Unavailable);
                    }
                    else
                    {
                        //confirm that we can build here
                        buildableInfo.buildable = true;
                        buildableInfo.position  = pos;

                        buildableInfo.platform = buildManager.buildPlatforms[i];
                        //Debug.Log(buildableInfo.platform+" !!!  "+buildManager.buildPlatforms[i]);
                    }

                    //check if the platform is walkable, if so, check if building on the point wont block all possible path
                    if (buildManager.buildPlatforms[i].IsWalkable())
                    {
                        //return true is the platform is not block
                        if (buildManager.buildPlatforms[i].CheckForBlock(pos, footprint))
                        {
                            //Debug.Log("all path is blocked "+Time.time);
                            status = _TileStatus.Blocked;
                        }
                    }

                    //~ buildableInfo.buildableType=buildManager.buildPlatforms[i].buildableType;
                    //~ buildableInfo.specialBuildableID=buildManager.buildPlatforms[i].specialBuildableID;

                    if (status == _TileStatus.Blocked)
                    {
                        List <TowerAvailability> tempList = new List <TowerAvailability>();
                        for (int n = 0; n < buildManager.buildPlatforms[i].towerAvaiList.Count; n++)
                        {
                            UnitTower tower = GetTower(buildManager.buildPlatforms[i].towerAvaiList[n].ID);
                            if (tower.type == _TowerType.Mine)
                            {
                                tempList.Add(buildManager.buildPlatforms[i].towerAvaiList[n]);
                            }
                        }
                        buildableInfo.towerAvaiList = tempList;
                    }
                    else
                    {
                        buildableInfo.towerAvaiList = buildManager.buildPlatforms[i].towerAvaiList;
                    }

                    break;
                }
            }
        }
        else
        {
            return(_TileStatus.NoPlatform);
        }

        currentBuildInfo = buildableInfo;

        if (buildManager.tileIndicatorMode != _TileIndicatorMode.None)
        {
            Utility.SetActive(indicator, true);
            indicator.transform.position = currentBuildInfo.position;
            if (currentBuildInfo.platform != null)
            {
                indicator.transform.rotation = currentBuildInfo.platform.thisT.rotation;
            }
        }

        return(status);
    }
コード例 #20
0
 static public void ClearBuildPoint()
 {
     //Debug.Log("ClearBuildPoint");
     currentBuildInfo = null;
     ClearIndicator();
 }
コード例 #21
0
ファイル: BuildManager.cs プロジェクト: wdj294/tdtk
 public static void ClearBuildPoint()
 {
     currentBuildInfo=null;
     ClearIndicator();
 }
コード例 #22
0
ファイル: BuildManager.cs プロジェクト: hanhonglei/Yotta
 public static void ClearBuildPoint()     //
 {
     currentBuildInfo = null;
 }
コード例 #23
0
ファイル: TechTree.cs プロジェクト: nevelis/OpenRA
 public void Add(string key, BuildableInfo info, ITechTreeElement tte)
 {
     watchers.Add(new Watcher( key, info, tte ));
 }