Esempio n. 1
0
    public void Initialize()
    {
        ResetBasic();
        ZeroBonus();
        ResetInfoBar();

        var host   = localMap[0, 0];
        var client = localMap[localMap.total_x - 1, 0];

        points = 0;
        state  = TurnState.NetWait;

        if (PhotonNetwork.isMasterClient)
        {
            turn_identity      = photonView.isMine ? 0 : 1;
            currentCell        = photonView.isMine ? host : client;
            transform.rotation = photonView.isMine ? q01 : q0_1;
        }
        else
        {
            turn_identity      = photonView.isMine ? 1 : 0;
            currentCell        = photonView.isMine ? client : host;
            transform.rotation = photonView.isMine ? q0_1 : q01;
        }
        currentCell.OnPlayerMoveIn(this);
    }
Esempio n. 2
0
 public override void OnBeingChoped(p3Player player, p3Cell sourceCell, int tier, int ac)
 {
     if (player != source & tier == 0 & state != StaticStructure.TreeState.InSeed)
     {
         return;
     }
     base.OnBeingChoped(player, sourceCell, tier, ac);
 }
Esempio n. 3
0
 /* x,z must be -1,0,1 or else ArrayOutOfBounds Exception */
 public void Link(int x, int z, p3Cell p)
 {
     if (map == null)
     {
         map       = new p3Cell[3, 3];
         map[1, 1] = this;
     }
     map[x + 1, z + 1] = p;
 }
Esempio n. 4
0
 public void OnPlayerChop(p3Player p, p3Cell chopedCell, int acCost)
 {
     if (chopedCell.tree != null)
     {
         chopedCell.tree.OnBeingChoped(p, p.currentCell, 0, acCost);
     }
     if (chopedCell.player != null & chopedCell.player != p)
     {
         chopedCell.player.OnBeingChoped(p, acCost);
     }
 }
Esempio n. 5
0
    virtual public void OnBeingChoped(p3Player player, p3Cell sourceCell, int tier, int acCost = 0)
    {
        if (state == TreeState.Falling | state == TreeState.WaitDomino)
        {
            return;
        }
        fx     = cell.x - sourceCell.x;
        fz     = cell.z - sourceCell.z;
        choper = player;

        ActivateOnChop(player, ref fx, ref fz);

        if (tier == 0)
        {
            player.OnChopDone(acCost);
        }

        if (!(fx == 0 & fz == 0))
        {
            fallingQuat     = Angle.Convert(fx, fz);
            dominoDelayTime = tier * p3Scene.Instance.globalDominoDelay;

            if (PassDominoFuther())
            {
                p3Cell c;
                if ((c = cell.Get(fx, fz)) != null)
                {
                    if (c.tree == null ? false : c.tree.CanBeAffectedByDomino())
                    {
                        c.tree.OnBeingChoped(player, cell, tier + 1);
                    }
                    else
                    {
                        player.OnCredit(tier);
                    }
                }
                else
                {
                    player.OnCredit(tier);
                }
            }
            else
            {
                Debug.Log("state == TreeState.InSeed ? " + (state == TreeState.InSeed));
                player.OnCredit(state == TreeState.InSeed? tier - 1 : tier);
            }

            dealDmg = state != TreeState.InSeed;
            state   = TreeState.WaitDomino;
        }
    }
Esempio n. 6
0
    public void CreateOne(byte x, byte z, float offx, float offz, float rootx, float rooty, float rootz)
    {
        total_x  = x;
        total_z  = z;
        offset_x = offx;
        offset_z = offz;
        root     = new Vector3(rootx, rooty, rootz);

        cells = new p3Cell[total_x, total_z];

        for (int _z = 0; _z < total_z; _z++)
        {
            for (int _x = 0; _x < total_x; _x++)
            {
                var g = Instantiate(cellPrefab);
                g.transform.parent = gameObject.transform;

                p3Cell c = g.GetComponent <p3Cell>();
                c.x = _x;
                c.z = _z;
                c.transform.position = Locate(_x, _z);
                c.Reset();

                cells[_x, _z] = c;

                g.transform.position = c.transform.position;
            }
        }
        for (int _z = 0; _z < total_z; _z++)
        {
            for (int _x = 0; _x < total_x; _x++)
            {
                var c = cells[_x, _z];
                c.Link(0, 1, _z + 1 < total_z? cells[_x, _z + 1] : null);
                c.Link(0, -1, _z - 1 >= 0 ? cells[_x, _z - 1] : null);
                c.Link(1, 0, _x + 1 < total_x ? cells[_x + 1, _z] : null);
                c.Link(-1, 0, _x - 1 >= 0 ? cells[_x - 1, _z] : null);

                c.Link(-1, 1, (_z + 1 < total_z & _x - 1 >= 0) ? cells[_x - 1, _z + 1] : null);
                c.Link(1, 1, (_z + 1 < total_z & _x + 1 < total_x) ? cells[_x + 1, _z + 1] : null);
                c.Link(1, -1, (_z - 1 >= 0 & _x + 1 < total_x) ? cells[_x + 1, _z - 1] : null);
                c.Link(-1, -1, (_z - 1 >= 0 & _x - 1 >= 0) ? cells[_x - 1, _z - 1] : null);
            }
        }
    }