public bool Update(IslandElement unit, float deltaTime)
        {
            if (!unit.HarvestInfo.CanHarvest(action) || !resource.HarvestInfo.CanBeHarvested(action))
            {
                return(true);
            }
            if ((unit.Position - resource.Position).sqrMagnitude > 2.0f)
            {
                harvestTime = 0f;
                if (gotoResourceAction == null || gotoResourceAction.Island != resource.Island || gotoResourceAction.RelativePosition != resource.RelativeToContainerPosition)
                {
                    gotoResourceAction = new GoToRelativePositionAction(resource.RelativeToContainerPosition,
                                                                        resource.Island, 1.0f);
                }
                gotoResourceAction.Update(unit, deltaTime);
                return(false);
            }
            if (harvestTime < harvestTimeCost)
            {
                harvestTime += deltaTime;
                return(false);
            }

            harvestTime -= harvestTimeCost;
            unit.HarvestController.Harvest(1f, resource);
            return(false);
        }
 public override void Init(IslandElement IslandElement, IslandElementDropOffControllerFactory IslandElementDropOffControllerFactory)
 {
     this.IslandElement = IslandElement;
     this.Fac           = IslandElementDropOffControllerFactory;
     IslandElement.DropOffController = this;
     base.Init(IslandElement, IslandElementDropOffControllerFactory);
     safeTime = 0;
 }
 public bool CanDo(IslandElement elem)
 {
     if (elem.Island == null)
     {
         return(false);
     }
     return(elem.CanUseMana);
 }
Beispiel #4
0
 private void FocusOnUnit(IslandElement u)
 {
     cam.SetUnit(u);
     m = m ?? new Mover(u, fP.ModelToEntity);
     inventoryView.FocusOn(u);
     cam.toFollow = u;
     m.unit       = u;
 }
Beispiel #5
0
 public bool Update(IslandElement islandElement, float deltaTime)
 {
     if (!spell.CanDo(islandElement))
     {
         return(true);
     }
     if (decoAction == null)
     {
         decoAction = spell.Do(islandElement);
     }
     return(decoAction.Update(islandElement, deltaTime));
 }
        public bool IsHostileTowards(IslandElement other)
        {
            if (Team == null)
            {
                return(false);
            }
            var otherTeam = other.TeamController.Team;

            if (otherTeam == null)
            {
                return(false);
            }
            return(Team.IsHostileTowards(otherTeam));
        }
        public bool Update(IslandElement islandElement, float deltaTime)
        {
            if (followed == null || !followed.IsAlive)
            {
                return(true);
            }
            gotoPos.Island = followed.Island;
            var distance =
                (islandElement.RelativeToContainerPosition - followed.RelativeToContainerPosition).magnitude;
            var intendedPosition = distance > followDistance + islandElement.CircleElementProperties.Radius + followed.CircleElementProperties.Radius ?
                                   followed.RelativeToContainerPosition
                : islandElement.RelativeToContainerPosition;

            gotoPos.RelativePosition = intendedPosition;
            gotoPos.Update(islandElement, deltaTime);
            return(false);
        }
Beispiel #8
0
 public bool Update(IslandElement islandElement, float deltaTime)
 {
     if (!islandElement.FightingController.CouldAttackIfCloseEnough(other))
     {
         return(true);
     }
     if (!islandElement.FightingController.IsCloseEnoughToAttack(other))
     {
         attackTime = 0f;
         ifNotCloseEnough.Update(islandElement, deltaTime);
         return(false);
     }
     attackTime += deltaTime;
     if (attackTime < 1f)
     {
         return(false);
     }
     attackTime -= 1f;
     islandElement.FightingController.Attack(other);
     return(false);
 }
 public virtual void Init(IslandElement IslandElement, ItemUsageControllerFactory ItemUsageControllerFactory)
 {
 }
 public FollowAction(IslandElement followed, float followDistance = 1f)
 {
     this.followDistance = followDistance;
     this.gotoPos        = new GoToRelativePositionAction(followed.RelativeToContainerPosition, followed.Island, 1f);
     this.followed       = followed;
 }
 public override void Init(IslandElement IslandElement, IslandElementTeamControllerFactory IslandElementTeamControllerFactory)
 {
     IslandElement.TeamController = this;
     base.Init(IslandElement, IslandElementTeamControllerFactory);
 }
 public virtual void Init(IslandElement IslandElement, IslandElementContainerManagerFactory IslandElementContainerManagerFactory)
 {
 }
 public override void Init(IslandElement IslandElement, IslandElementActionHandlerFactory UnitActionHandlerFactory)
 {
     this.Unit = IslandElement;
     this.UnitActionHandlerFactory = UnitActionHandlerFactory;
     IslandElement.ActionHandler   = this;
 }
 public virtual void Init(IslandElement IslandElement, IslandElementElementalViewFactory IslandElementElementalViewFactory)
 {
 }
 public virtual void Init(IslandElement IslandElement, IslandElementUnityStatsViewFactory IslandElementUnityStatsViewFactory)
 {
 }
 public virtual void Init(IslandElement IslandElement, IslandElementLightControllerFactory IslandElementLightControllerFactory)
 {
 }
Beispiel #17
0
 public virtual void Init(IslandElement IslandElement, HarvestControllerFactory HarvestControllerFactory)
 {
 }
 public IIslandElementAction Do(IslandElement elem)
 {
     return(new HarvestIslandManaAction(elem.ElementalInfo.MagmaLevel, harvest));
 }
Beispiel #19
0
 public virtual void Init(IslandElement IslandElement, InventoryControllerFactory InventoryControllerFactory)
 {
 }
 public bool CanSee(IslandElement elem)
 {
     return(true);
 }
 public FollowAndProtectCommand(IslandElement toFollow)
 {
     follow = toFollow;
 }
Beispiel #22
0
 public AttackAction(IslandElement other)
 {
     this.other       = other;
     ifNotCloseEnough = new FollowAction(other, 0f);
     attackTime       = 0f;
 }
 public virtual void Init(IslandElement IslandElement, IslandElementDropOffControllerFactory IslandElementDropOffControllerFactory)
 {
 }
 public virtual void Init(IslandElement IslandElement, IslandElementHydrationControllerFactory IslandElementHydrationControllerFactory)
 {
 }
 public override void Init(IslandElement IslandElement, CollisionSizeManagerFactory CollisionSizeManagerFactory)
 {
     this.IslandElement = IslandElement;
     this.fac           = CollisionSizeManagerFactory;
     base.Init(IslandElement, CollisionSizeManagerFactory);
 }
 public HarvestResourceAction(IslandElement resource, HarvestAction action)
 {
     harvestTime   = 0f;
     this.resource = resource;
     this.action   = action;
 }
 public virtual void Init(IslandElement IslandElement, NearOthersControllerFactory NearOthersControllerFactory)
 {
 }
Beispiel #28
0
 public override void Init(IslandElement IslandElement, IslandElementElementalControllerFactory IslandElementElementalControllerFactory)
 {
     this.elem = IslandElement;
     elem.ElementalController = this;
     base.Init(IslandElement, IslandElementElementalControllerFactory);
 }
 public virtual void Init(IslandElement IslandElement, CollisionSizeManagerFactory CollisionSizeManagerFactory)
 {
 }
 public virtual void Init(IslandElement IslandElement, IslandElementUnityAnimationControllerFactory IslandElementUnityAnimationControllerFactory)
 {
 }