Ejemplo n.º 1
0
    public void OnMapZoneTouchMove(Vector2 pos)
    {
        var cell = localMap.GetPointedCell(pos);

        if (cell == null)
        {
            if (lastPointedCell != null)
            {
                lastPointedCell.SelectedOn(false);
                lastPointedCell = null;
            }
            return;
        }
        //if ( Mathf.Abs(cell.x - currentCell.x ) > 1 | Mathf.Abs(cell.z - currentCell.z) > 1 ) return;

        if (lastPointedCell != null & lastPointedCell != cell)
        {
            // turn off highlight last cell
            lastPointedCell.SelectedOn(false);
            if (lastPointedCell.tree != null)
            {
                lastPointedCell.tree.OnTouchExit();
            }
            if (cell.tree != null)
            {
                cell.tree.OnTouchEnter();
            }
        }
        lastPointedCell = cell;
        // turn on highlight
        lastPointedCell.SelectedOn(true);
    }
Ejemplo n.º 2
0
    public void Initialize()
    {
        localMap    = p2Map.Instance;
        globalScene = p2Scene.Instance;
        gui         = p2Gui.Instance;

        ResetBasic();
        ZeroBonus();

        var host   = localMap[0, 0];
        var client = localMap[localMap.total_x - 1, 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);
    }
Ejemplo n.º 3
0
 /* x,z must be -1,0,1 or else ArrayOutOfBounds Exception */
 public void Link(int x, int z, p2Cell p)
 {
     if (map == null)
     {
         map       = new p2Cell[3, 3];
         map[1, 1] = this;
     }
     map[x + 1, z + 1] = p;
 }
Ejemplo n.º 4
0
    //List<p2FallRecord > markedToFallList = new List<p2FallRecord>();
//	bool hasJobInThisTurn = false;

    public void OnPlayerChop(p2Player p, p2Cell 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);
        }
    }
Ejemplo n.º 5
0
    virtual public void OnBeingChoped(p2Player player, p2Cell 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 (!(fx == 0 & fz == 0))
        {
            if (tier == 0)
            {
                player.OnChopDone(acCost);
            }
            fallingQuat     = Angle.Convert(fx, fz);
            dominoDelayTime = tier * p2Scene.Instance.globalDominoDelay;

            if (PassDominoFuther())
            {
                p2Cell 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
            {
                player.OnCredit(state == TreeState.InSeed? tier - 1 : tier);
            }

            dealDmg = state != TreeState.InSeed;
            state   = TreeState.WaitDomino;
        }
    }
Ejemplo 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 p2Cell[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;

                p2Cell c = g.GetComponent <p2Cell>();
                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);
            }
        }
    }