Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        input = GameObject.Find("Input Handler").GetComponent <InputHandler>();

        //Find hud object  in scene
        findHUD();

        animator = transform.GetChild(0).GetComponent <Animator>();

        Renderer rend = transform.GetChild(0).GetChild(1).GetComponent <SkinnedMeshRenderer>();

        color = rend.material.color;

        //Determine if player 1 for key input purposes. Reverse the values to give keyboard input to player 2.
        if (playerNumber == 0 && !onlineOpponent)
        {
            player1 = true;
        }
        else
        {
            player1 = false;
        }

        //Initialize character controller for movemnet
        controller       = gameObject.GetComponent <CharacterController>();
        cameraController = cameraHandler.GetComponent <CameraController>();

        //Initialize some bomb throwing and bomb crafting related variables
        canThrow             = true;
        firstThrow           = false; //Unusued first throw thing
        bombHandlerReference = GameObject.FindGameObjectsWithTag("BombList")[0];
        bombHandler          = bombHandlerReference.GetComponent <BombCraftingHandler>();
        selectedBomb         = 0;

        statManager = GameObject.Find("GameManager").GetComponent <ReadAndWriteStats>();

        explosionForce = new Vector3(0.0f, 0.0f, 0.0f);

        //Child stuff for throw feedback
        if (!onlineOpponent)
        {
            throwBar   = cameraHandler.transform.GetChild(0).gameObject;
            aimingQuad = transform.GetChild(1).gameObject;
            throwArc   = aimingQuad.GetComponent <LaunchArcMesh>();
        }

        //Inventory stuff
        for (int i = 0; i < 4; i++)
        {
            materialCount[i] = 0;
            materialID[i]    = 0;

            if (!onlineOpponent)
            {
                textForHUD[0].text = materialCount[i].ToString();
            }

            activeCraftingMaterial[i] = false;

            dpadReleased[i] = false;
        }

        //Make sure bomb inventory structure stuff are at default values.
        for (int i = 0; i < 5; i++)
        {
            makeBombDefaults(ref craftedBombs[i]);
        }
        makeBombDefaults(ref newerBomb);
        setInventoryText();

        dyingAnimation = false;

        throwingPower      = -0.1f;
        health             = 100.0f;
        invinciblityFrames = 0.0f;
        //Status effect stuff
        stunned = 0.0f;
        burning = 0.0f;
    }
Exemplo n.º 2
0
    //Read in a bomb message and spawn it with whatever attributes
    void parseBombMessage(int playerNo, string msg, Vector3 pos, Vector3 vel)
    {
        Debug.Log("Bomb msg: " + msg);

        BombCraftingHandler bombCraftingHandler = GameObject.FindGameObjectsWithTag("BombList")[0].GetComponent <BombCraftingHandler>();
        GameObject          bomb = bombCraftingHandler.bombs[0];

        float[] newAttribues = new float[10];

        string currentVarMsg   = "";
        int    currentVarIndex = 0;


        //First find the player that threw it to animate a throw

        /*if (playerNo < serverPlayers.Count)
         * {
         * if (serverPlayers[playerNo] != null && serverPlayers[playerNo].animator != null)
         * serverPlayers[playerNo].animator.SetBool("throwing", true);
         * }*/

        //Parse attribute message for a variety of bomb variables
        for (int i = 1; i < msg.Length; i++)
        {
            //New var on space
            if (msg[i] == ' ')
            {
                if (currentVarIndex < 10)
                {
                    newAttribues[currentVarIndex] = float.Parse(currentVarMsg);
                }

                //Reset current variable string and increase variable index
                currentVarMsg = "";
                currentVarIndex++;
            }
            else if (msg[i] == ',') //Do nothing on commas
            {
            }
            else
            {
                currentVarMsg += msg[i];
            }
        }


        //The new bomb is ready to be spawned.
        GameObject newBomb = Instantiate(bomb, pos, transform.rotation);

        newBomb.GetComponent <Rigidbody>().velocity = vel;

        Bomb newBombClass = newBomb.GetComponent <Bomb>();

        newBombClass.attributes = default(BombAttributes.BombData);

        //All attributes look at the array just used in the previous for loop.
        newBombClass.attributes.explosionScaleSpeed = new Vector3(15.0f, 15.0f, 15.0f); // Always the same :P
        newBombClass.attributes.explosionLifetime   = newAttribues[1];
        newBombClass.attributes.explosionScaleLimit = newAttribues[2];
        newBombClass.attributes.damage    = newAttribues[3];
        newBombClass.attributes.fire      = (int)newAttribues[4];
        newBombClass.attributes.freeze    = (int)newAttribues[5];
        newBombClass.attributes.smoke     = (int)newAttribues[6];
        newBombClass.attributes.blackhole = (int)newAttribues[7];
        newBombClass.attributes.scatter   = (int)newAttribues[8];
        newBombClass.attributes.MaxRange  = newAttribues[9];
    }
Exemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        findHUD();

        animator = transform.GetChild(0).GetComponent <Animator>();

        Renderer rend = transform.GetChild(0).GetChild(1).GetComponent <SkinnedMeshRenderer>();

        color = rend.material.color;

        //Determine if player 1 for key input purposes. Reverse the values to give keyboard input to player 2.
        if (playerInputString == "")
        {
            player1 = true;
        }
        else
        {
            player1 = false;
        }

        //Initialize some stuff
        //m_Rigidbody = gameObject.GetComponent<Rigidbody>(); //Get rigid body for movemnt stuff below
        controller           = gameObject.GetComponent <CharacterController>();
        canThrow             = true;
        bombHandlerReference = GameObject.FindGameObjectsWithTag("BombList")[0];
        bombHandler          = bombHandlerReference.GetComponent <BombCraftingHandler>();
        selectedBomb         = 0;

        statManager = GameObject.Find("GameManager").GetComponent <ReadAndWriteStats>();

        explosionForce = new Vector3(0.0f, 0.0f, 0.0f);

        throwBar   = cameraHandler.transform.GetChild(0).gameObject;
        aimingQuad = transform.GetChild(1).gameObject;

        //Inventory stuff
        for (int i = 0; i < 4; i++)
        {
            materialCount[i]          = 0;
            materialID[i]             = 0;
            textForHUD[0].text        = materialCount[i].ToString();
            activeCraftingMaterial[i] = false;

            dpadReleased[i] = false;
        }

        //Make sure bomb inventory structure stuff are at default values.
        for (int i = 0; i < 5; i++)
        {
            makeBombDefaults(ref craftedBombs[i]);
        }
        makeBombDefaults(ref newerBomb);
        setInventoryText();

        dyingAnimation = false;

        throwingPower      = -0.1f;
        health             = 100.0f;
        invinciblityFrames = 0.0f;
        //Status effect stuff
        stunned = 0.0f;
        burning = 0.0f;
    }