コード例 #1
0
    public bool PlayerMove(LogicJack jack, int x, int y)
    {
        if (!jack.ValidMoveRange(x, y))
        {
            return(false);
        }
        if (jack.x == x & jack.y == y)
        {
            return(false);
        }

        int ac_remain    = jack.ac - 1; // default cost
        int priorityLock = 0;

        if (onPlayerTryMove != null)
        {
            onPlayerTryMove(jack, ref ac_remain, ref priorityLock);
        }

        if (ac_remain < 0)
        {
            Debug.Log("not enough ac");
            return(false);
        }

        jack.ac = ac_remain;
        jack.MoveTo(x, y);

        if (onPlayerMoveDone != null)
        {
            onPlayerMoveDone(jack);
        }
        return(true);
    }
コード例 #2
0
 public override bool BeingChopped(LogicJack jack, bool directly)
 {
     Debug.LogError("!MODIFIED FOR TEST PURPOSE ONLY !");
     return(true);
     //if (!directly & growth == Growth.FullGrown) return false;
     // return true;
 }
コード例 #3
0
 virtual public void Init(LogicPlayground logicPlayground, int _x, int _y, LogicJack _owner, Growth _growth = Growth.Small)
 {
     x      = _x;
     y      = _y;
     growth = _growth;
     owner  = _owner;
 }
コード例 #4
0
ファイル: Server.cs プロジェクト: Yetij/LumberjackDuel
    void Start()
    {
        Debug.Log("Server Start");
        playground = new LogicPlayground(gridX, gridY, offsetX, offsetY);

        character = new LogicJack[2];

        var l1 = new LogicJack(PLAY.ER1, 0, 0);

        l1.ac        = acPerTurn;
        character[0] = l1;

        var l2 = new LogicJack(PLAY.ER2, gridX - 1, 0);

        l2.ac        = acPerTurn;
        character[1] = l2;

        l1.Opponent = l2;
        l2.Opponent = l1;

        ready = new bool[2] {
            false, false
        };

        photonView.RPC("InitClient", PhotonTargets.AllViaServer, gridX, gridY, offsetX, offsetY);
    }
コード例 #5
0
 internal bool BeingChop(LogicJack logicJack)
 {
     // hp --;
     //throw new NotImplementedException();
     UnityEngine.Debug.Log("Unimplemented feature ");
     return(true);
 }
コード例 #6
0
 private bool ChopTree2(LogicJack jack, LogicTree logicTree, bool directly = true)
 {
     if (logicTree.BeingChopped(jack, directly))
     {
         cellControl[logicTree.x, logicTree.y] = null;
         logicTree.Flush(this);
         return(true);
     }
     return(false);
 }
コード例 #7
0
ファイル: l_Swamp.cs プロジェクト: Yetij/LumberjackDuel
 private void MakeThemMoveHarder(LogicJack jack, ref int ac_remain, ref int priorityLock)
 {
     if (slow_priotiy < priorityLock)
     {
         return;
     }
     if (!this.InRange(jack, area))
     {
         return;
     }
     ac_remain -= slow_penalty;   // normal move cost = 1;
 }
コード例 #8
0
    public bool ChopPlayer(LogicJack chopper, LogicJack another)
    {
        if (!chopper.ValidChopRange(another.x, another.y))
        {
            return(false);
        }

        int dirx = another.x - chopper.x;
        int diry = another.y - chopper.y;

        int ac_remain    = chopper.ac;
        int priorityLock = 0;

        if (onPlayerTryChop != null)
        {
            onPlayerTryChop(chopper, ref ac_remain, ref dirx, ref diry, ref priorityLock);
        }

        if (dirx == 0 & diry == 0)
        {
            return(false);
        }

        if (ac_remain < 0)
        {
            return(false);
        }
        chopper.ac = ac_remain;
        another.BeingChop(chopper);

        if (onPlayerChopDone != null)
        {
            int zero = 0;
            onPlayerChopDone(chopper, ref zero);
        }

        return(true);
    }
コード例 #9
0
ファイル: l_BonusAc.cs プロジェクト: Yetij/LumberjackDuel
 public override void Init(LogicPlayground logicPlayground, int _x, int _y, LogicJack _owner, Growth _growth = Growth.Small)
 {
     base.Init(logicPlayground, _x, _y, _owner, _growth);
     logicPlayground.onTurnChange += GiveBonusAc;
     type = TreeType.BonusAc;
 }
コード例 #10
0
 public static bool InRange(this LogicTree tree, LogicJack jack, int area)
 {
     return(Mathf.Abs(tree.x - jack.x) <= area& Mathf.Abs(tree.y - jack.y) <= area);
 }
コード例 #11
0
 internal void AfterChop(LogicJack jack, ref int earned_point)
 {
 }
コード例 #12
0
 virtual public bool BeingChopped(LogicJack jack, bool directly)
 {
     return(true);
 }
コード例 #13
0
    public bool ChopTree(LogicJack jack, int x, int y, out List <LogicTree> domino)
    {
        domino = null;

        if (!jack.ValidChopRange(x, y))
        {
            return(false);
        }

        if (!ValidIndex(x, y))
        {
            Debug.LogError("wtf ? x,y= " + x + "," + y);
            return(false);
        }

        int dirx = x - jack.x;
        int diry = y - jack.y;

        int ac_remain    = jack.ac - 1; // default cost = 1;
        int priorityLock = 0;

        if (onPlayerTryChop != null)
        {
            onPlayerTryChop(jack, ref ac_remain, ref dirx, ref diry, ref priorityLock);
        }

        if (dirx == 0 & diry == 0)
        {
            return(false);
        }

        if (ac_remain < 0)
        {
            return(false);
        }

        var tree = cellControl[x, y];

        if (!ChopTree2(jack, tree))
        {
            return(false);
        }

        //tree chop succeeded
        jack.ac = ac_remain;
        domino  = new List <LogicTree>();

        for (int i = x + dirx, j = y + diry; i < gridX & i >= 0 & j < gridY & j >= 0; i += dirx, j += diry)
        {
            var t = cellControl[i, j];
            if (t != null)
            {
                if (!ChopTree2(jack, t, false))
                {
                    break;
                }
                domino.Add(t);
                if (!t.PassDomino())
                {
                    break;
                }
            }
            else
            {
                break;
            }
        }

        int earned_point = jack.EstimateEarnedPoints(tree, domino);

        tree.AfterChop(jack, ref earned_point);
        foreach (var _t in domino)
        {
            _t.AfterChop(jack, ref earned_point);
        }

        if (onPlayerChopDone != null)
        {
            onPlayerChopDone(jack, ref earned_point);
        }

        jack.points += earned_point;

        return(true);
    }
コード例 #14
0
    public bool PlantTree(LogicJack[] jacks, int player, TreeType treeSelected, int x, int y)
    {
        if (!ValidIndex(x, y))
        {
            Debug.LogError("wtf ? x,y= " + x + "," + y);
            return(false);
        }

        if (cellControl[x, y] != null)
        {
            Debug.LogError("there is already a tree at " + x + "," + y);
            return(false);
        }

        foreach (var j in jacks)
        {
            if (j.x == x & j.y == y)
            {
                return(false);
            }
        }

        if (treeSelected == TreeType.None)
        {
            return(false);
        }

        LogicJack logicJack = null;

        if (player >= 0)
        {
            logicJack = jacks[player];
            if (!logicJack.ValidPlantRange(x, y))
            {
                return(false);
            }

            int ac_remain    = logicJack.ac - 1; // default plant cost
            int priorityLock = 0;
            if (onPlayerTryPlant != null)
            {
                onPlayerTryPlant(logicJack, ref ac_remain, ref priorityLock);
            }

            if (ac_remain < 0)
            {
                return(false);
            }
            logicJack.ac = ac_remain;
        }

        LogicTree tree = GetTree(treeSelected);

        tree.Init(this, x, y, logicJack);
        cellControl[x, y] = tree;

        if (onPlayerPlantDone != null & player >= 0)
        {
            onPlayerPlantDone(logicJack);
        }
        return(true);
    }
コード例 #15
0
ファイル: l_Ethereal.cs プロジェクト: Yetij/LumberjackDuel
 public override bool BeingChopped(LogicJack jack, bool directly)
 {
     return(directly? (jack == owner) : true);
 }
コード例 #16
0
ファイル: l_Swamp.cs プロジェクト: Yetij/LumberjackDuel
 public override void Init(LogicPlayground logicPlayground, int _x, int _y, LogicJack _owner, Growth _growth = Growth.Small)
 {
     base.Init(logicPlayground, _x, _y, _owner, _growth);
     logicPlayground.onPlayerTryMove += MakeThemMoveHarder;
     type = TreeType.Swamp;
 }
コード例 #17
0
ファイル: l_BasicTree.cs プロジェクト: Yetij/LumberjackDuel
 public override void Init(LogicPlayground logicPlayground, int _x, int _y, LogicJack _owner, Growth _growth = Growth.Small)
 {
     base.Init(logicPlayground, _x, _y, _owner, _growth);
     type = TreeType.Basic;
 }
コード例 #18
0
 public override bool BeingChopped(LogicJack jack, bool directly)
 {
     return(false);
 }