Example #1
0
    public void EndTargetPhase(MetaAction metaAction, ActionInfo actionInfo)
    {
        foreach (ui_ability_script b in buttonManager)
        {
            b.TurnOffHighlight();
        }

        ActionDist actions = metaAction.Execute(actionInfo);

        this.board.world.ExecuteActionDist(actions);
        this.EndTurn();
    }
Example #2
0
 public void ExecuteActionDist(World world, ActionDist distro)
 {
     if (!distro.IsDegenerated())
     {
         this.splitLock.SignalStart();
         StartCoroutine(this.SplitWorld(world, distro));
     }
     else
     {
         // TODO this should probably look for the action which has weight 1!
         world.EnqueueAction(distro.GetAction(0));
         world.ExecuteNextAction();
     }
 }
Example #3
0
    public IEnumerator SplitWorld(World world, ActionDist distro)
    {
        QuadTree.Node worldNode  = (QuadTree.Node) this.worldTree.nodesByWorldId[world.id];
        Vector3[]     newOrigins = this.OriginsAfterSplit(world);
        float         newScale   = WorldManager.ScaleAfterSplit(world);
        List <int>    hues       = new List <int>();

        while (hues.Count < 4)
        {
            int hue = UnityEngine.Random.Range(0, 360);
            if (hues.All(x => Math.Abs(x - hue) > 10))
            {
                hues.Add(hue);
            }
        }



        World[] newWorlds = new World[4];
        for (int i = 0; i < 4; i++)
        {
            newWorlds[i] = this.CopyWorld(world,
                                          newOrigins[i],
                                          newScale,
                                          world.integrity * distro.GetWeight(i), hues[i]);
            newWorlds[i].EnqueueAction(distro.GetAction(i));
        }

        // Add new worlds to the tree
        this.worldTree.SplitNode(worldNode, newWorlds);
        this.DestroyWorld(world);

        while (this.AnyWorldLocked())
        {
            yield return(new WaitForEndOfFrame());
        }

        for (int i = 0; i < 4; i++)
        {
            newWorlds[i].ExecuteNextAction();
            while (newWorlds[i].Locked())
            {
                yield return(null);
            }
        }
        this.splitLock.SignalStop();
        yield break;
    }
Example #4
0
 public override ActionDist Execute(ActionInfo info)
 {
     ActionWeightPair[] weightedActions = new ActionWeightPair[4];
     if (info.targetId != World.InvalidId && info.originId != World.InvalidId)
     {
         weightedActions[0] = new ActionWeightPair(new SwapAction(info), 1);
         weightedActions[1] = new ActionWeightPair(new NonAction(), 0);
         weightedActions[2] = new ActionWeightPair(new NonAction(), 0);
         weightedActions[3] = new ActionWeightPair(new NonAction(), 0);
         return(new ActionDist(weightedActions));
     }
     else
     {
         return(ActionDist.DegeneratedNonActions());
     }
 }
Example #5
0
 public override ActionDist Execute(ActionInfo info)
 {
     ActionWeightPair[] weightedActions = new ActionWeightPair[4];
     if (info.targetId != World.InvalidId && info.originId != World.InvalidId)
     {
         Vector2Int[] moves = { new Vector2Int(0, 1), new Vector2Int(0, -1), new Vector2Int(1, 0), new Vector2Int(-1, 0), };
         for (int i = 0; i < moves.Length; i++)
         {
             weightedActions[i] = new ActionWeightPair
                                  (
                 new MoveAction(info, moves[i]),
                 0.25f
                                  );
         }
         return(new ActionDist(weightedActions));
     }
     else
     {
         return(ActionDist.DegeneratedNonActions());
     }
 }
Example #6
0
 public void ExecuteActionDist(ActionDist distro)
 {
     this.manager.ExecuteActionDist(this, distro);
 }
Example #7
0
 public static ActionDist DegeneratedNonActions()
 {
     return(ActionDist.NonActions(new float[] { 1.0f, 0, 0, 0 }));
 }
Example #8
0
 public static ActionDist NonActions()
 {
     return(ActionDist.NonActions(new float[] { 0.25f, 0.25f, 0.25f, 0.25f }));
 }