Inheritance: MonoBehaviour
示例#1
0
    public void Start()
    {
        groundArrayCopy = new GroundManager.groundNode[32, 32, 32];

        groundManager = GameObject.Find("GameManager").GetComponent <GroundManager>();
        crabManager   = GameObject.Find("GameManager").GetComponent <CrabManager>();

        //get a copy of ground array for each crab
        for (int i = 0; i < 32; i++)
        {
            for (int j = 0; j < 32; j++)
            {
                for (int k = 0; k < 32; k++)
                {
                    groundArrayCopy[i, j, k] = groundManager.groundArray[i, j, k];
                }
            }
        }
        //addthis crab to the queue of crabs
        crabManager.crabs.Add(this);

        //mark current square as occupied
        Vector3 arrayPos = groundManager.worldToArray(parentSquare.transform.position);

        root            = groundArrayCopy[(int)arrayPos.x, (int)arrayPos.y, (int)arrayPos.z];
        root.square.tag = "Occupied";
    }
示例#2
0
    // Use this for initialization
    void Start()
    {
        Debug.Log("Starting Network Manager");
        button = new Rect(Screen.width - 130, Screen.height - 50, 120, 40);
        //Debug.Log(CryptoHelper.GetMd5String("Hello World!"));

        gm      = GameManager.GetInstance();
        newname = username = gm.username;
        hostIp  = gm.ipAddress;

        console = new List <string>();
        lobby   = new List <string>();

        Players = new List <PlayerObject>();

        if (!gm.isSoloPlay)
        {
            NetPeerConfiguration config = new NetPeerConfiguration("crab_battle");

            client = new NetClient(config);

            NetOutgoingMessage outmsg = new NetOutgoingMessage();

            client.Start();
            outmsg.Write("A Client");
            client.Connect(hostIp, gm.gamePort, outmsg);

            AddConsoleMessage("Waiting for connection to server...");
        }
        else
        {
            isConnected = true; // In solo mode, we're always connected!
            //username = PlayerPrefs.GetString("Username", "Player");
            //newname = username;
            gm.isReady = true;
            ClientId   = 1;
        }

        windowrect = new Rect(Screen.width / 2f - 100f, Screen.height / 2f - 150f, 200f, 310f);
        lobbyrect  = new Rect(Screen.width / 2f - 200f, Screen.height - 100f, 400f, 100f);

        Enemy = GameObject.Instantiate(Resources.Load("battlecrab"), Vector3.zero, Quaternion.identity) as GameObject;
        Enemy.animation.Play("laying");

        EnemyManager = Enemy.GetComponent <CrabManager>();
        lastSec      = Time.time;
    }
示例#3
0
    // Use this for initialization
    void Start()
    {
        Debug.Log("Starting Network Manager");
        button = new Rect(Screen.width - 130, Screen.height -50, 120, 40);
        //Debug.Log(CryptoHelper.GetMd5String("Hello World!"));

        gm = GameManager.GetInstance();
        newname = username = gm.username;
        hostIp = gm.ipAddress;

        console = new List<string>();
        lobby = new List<string>();

        Players = new List<PlayerObject>();

        if (!gm.isSoloPlay)
        {
            NetPeerConfiguration config = new NetPeerConfiguration("crab_battle");

            client = new NetClient(config);

            NetOutgoingMessage outmsg = new NetOutgoingMessage();

            client.Start();
            outmsg.Write("A Client");
            client.Connect(hostIp, gm.gamePort, outmsg);

            AddConsoleMessage("Waiting for connection to server...");
        }
        else
        {
            isConnected = true; // In solo mode, we're always connected!
            //username = PlayerPrefs.GetString("Username", "Player");
            //newname = username;
            gm.isReady = true;
            ClientId = 1;
        }

        windowrect = new Rect(Screen.width / 2f - 100f, Screen.height / 2f - 150f, 200f, 310f);
        lobbyrect = new Rect(Screen.width / 2f - 200f, Screen.height - 100f, 400f, 100f);

        Enemy = GameObject.Instantiate(Resources.Load("battlecrab"), Vector3.zero, Quaternion.identity) as GameObject;
        Enemy.animation.Play("laying");

        EnemyManager = Enemy.GetComponent<CrabManager>();
        lastSec=Time.time;
    }