Example #1
0
    void Update()
    {
        // Add the time since Update was last called to the timer.
        timer += Time.deltaTime;

        // Set up the Editor before calling into the realtime database.
        FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://huntar-3db6a.firebaseio.com/");

        // Get the root reference location of the database.
        DatabaseReference reference = FirebaseDatabase.DefaultInstance.RootReference;

        // Pull Data from particular location in database
        FirebaseDatabase.DefaultInstance
        .GetReference("users").Child("I0be6MxSRzMDf9kTxcf4pJYklbx1").Child("combatInstance").Child("combatInstance").Child("damagepershot")
        .GetValueAsync().ContinueWith(task => {
            if (task.IsFaulted)
            {
                // Handle the error...
            }
            else if (task.IsCompleted)
            {
                DataSnapshot snapshot = task.Result;
                // Do something with snapshot...
                damagePerShot = Int32.Parse(snapshot.Value.ToString());
            }
        });

        FirebaseDatabase.DefaultInstance
        .GetReference("users").Child("I0be6MxSRzMDf9kTxcf4pJYklbx1").Child("combatInstance").Child("combatInstance").Child("characterfirerate")
        .GetValueAsync().ContinueWith(task => {
            if (task.IsFaulted)
            {
                // Handle the error...
            }
            else if (task.IsCompleted)
            {
                DataSnapshot snapshot = task.Result;
                // Do something with snapshot...
                float f            = Convert.ToSingle(snapshot.Value);
                timeBetweenBullets = f;
            }
        });

        // If there is input on the shoot direction stick and it's time to fire...
        if ((SimpleJoystick.GetJoystickState("Shoot") == true) && timer >= timeBetweenBullets)
        {
            // ... shoot the gun
            Shoot();
        }
        // If the timer has exceeded the proportion of timeBetweenBullets that the effects should be displayed for...
        if (timer >= timeBetweenBullets * effectsDisplayTime)
        {
            // ... disable the effects.
            DisableEffects();
        }
    }
Example #2
0
    // Use this for initialization
    void Start()
    {
        if (null == joystick)
        {
            joystick = GameObject.FindObjectOfType <SimpleJoystick>();
        }

        fc = GetComponent <SimpleFellowCamera>();


        NavMeshTriangulation tmpNavMeshTriangulation = NavMesh.CalculateTriangulation();

        hasMavMesh = tmpNavMeshTriangulation.vertices.Length > 0;
    }
Example #3
0
    // Use this for initialization
    void Awake()
    {
        if (!MovementJoystick)
        {
            MovementJoystick = GameObject.FindGameObjectWithTag(Tags.Joystick).GetComponent <SimpleJoystick>();
        }


        if (gameObject.GetComponent <CharacterController>() != null)
        {
            isCharacterControllerAttached = true;
            character_controller          = gameObject.GetComponent <CharacterController>();
        }
        else
        {
            isCharacterControllerAttached = false;
            rigid_body = GetComponentInChildren <Rigidbody>();
        }
    }
Example #4
0
    protected void InstantiateButton()
    {
        cooldownPrefab.transform.localPosition = new Vector3(xPosition, yPosition);
        cooldownPrefab.transform.localScale    = new Vector3(scale, scale);
        cooldownPrefab.GetComponent <CoolDownSkill>().coolDownTime = skill.GetCoolDownTime();
        skill.SetCooldown(Instantiate(cooldownPrefab, canvas.transform, false));

        virtualJoyStickPrefab.transform.localPosition = new Vector3(xPosition, yPosition);
        virtualJoyStickPrefab.transform.localScale    = new Vector3(scale, scale);
        SimpleJoystick joyStick = virtualJoyStickPrefab.GetComponent <SimpleJoystick>();

        joyStick.HorizontalAxisName = horizontalButtonName;
        joyStick.VerticalAxisName   = verticalButtonName;
        SimpleButton button = virtualJoyStickPrefab.GetComponent <SimpleButton>();

        button.ButtonName = simpleButtonName;
        ButtonImage buttonImg = virtualJoyStickPrefab.GetComponentInChildren <ButtonImage>();

        buttonImg.changeImage(buttonImage);
        Instantiate(virtualJoyStickPrefab, canvas.transform, false);
    }