Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Z))
        {
            // start putting hurt trap
            trapping = true;
            trapType = 1;
        }
        if (Input.GetKeyDown(KeyCode.X))
        {
            // start putting slow trap
            trapping = true;
            trapType = 2;
        }
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            // cancel tmp trap
            trapping = false;
            if (tmpTrap != null)
            {
                Destroy(tmpTrap);
            }
        }
        if (Input.GetKeyDown(KeyCode.Space))
        {
            // put trap down
            if (trapping && validTmpTrapFlag)
            {
                trapping = false;
                // Generate trap
                if (trapType == 1)
                {
                    trapManager.GenerateHurtTrap(tmpTrap.transform.position, mainPlayerController.playerId);
                }
                else if (trapType == 2)
                {
                    trapManager.GenerateSlowTrap(tmpTrap.transform.position, mainPlayerController.playerId);
                }
                Destroy(tmpTrap);
            }
        }

        if (trapping)
        {
            // update trap position due to ray
            UpdateTmpTrap();
        }
    }