public SocialRunViewModel()
        {
            StartRun = new RelayCommand(() =>
            {
                BuddyRunManager.Instance.Start();
                StopRun.RaiseCanExecuteChanged();
                StartRun.RaiseCanExecuteChanged();
            },
                                        () => { return(!BuddyRunManager.Instance.InRun /*&& BandService.Instance.IsConnected*/); });

            StopRun = new RelayCommand(() =>
            {
                BuddyRunManager.Instance.Stop();
                StopRun.RaiseCanExecuteChanged();
                StartRun.RaiseCanExecuteChanged();
            },
                                       () => { return(BuddyRunManager.Instance.InRun); });

            BuddyRunManager.Instance.OnRouteUpdate    += Instance_OnRouteUpdate;
            LocationService.Instance.OnLocationChange += Instance_OnLocationChange;
            BandService.Instance.OnHeartRateChange    += Instance_OnHeartRateChange;
            CurrentLocation = ExtentionMethods.GetDefaultPoint();
            BuddyLocation   = ExtentionMethods.GetDefaultPoint();
            BuddyRunManager.Instance.OnBuddyRouteUpdate    += Instance_OnBuddyRouteUpdate;
            BuddyRunManager.Instance.OnBuddyLocationUpdate += Instance_OnBuddyLocationUpdate;
        }
Exemple #2
0
        public string SetAntlr(BlockInfo block)
        {
            StringBuilder strBuilder = new StringBuilder();

            isPricer = block.IsPricer;
            try
            {
                strBuilder.Append("{ ");
                strBuilder.Append(BlockStartTag(block));
                foreach (var item in block.Statements)
                {
                    SetStatement(item, strBuilder);
                }
                if (block.ReturnVariable != null)
                {
                    strBuilder.Append(BlockEndTag(block));
                }
                strBuilder.Append(" }");
                string antlrStr = ExtentionMethods.TrimMultipleWhiteSpace(strBuilder.ToString()).Replace(" ; ;", " ;");



                string l_err = ValidateAntlr(antlrStr);
                if (!string.IsNullOrEmpty(l_err))
                {
                    throw new Exception(l_err);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return("");
        }
Exemple #3
0
 void FixedUpdate()
 {
     //caluclate the movement of the blade in various scenarious, to provide data f
     if (bladeSystem.isEmitting == true && colour == 4)
     {
         //print(Vector3.Dot(head.forward, transform.forward) + " " + holderCont.velocity);
         if (holderCont.velocity.sqrMagnitude > 4 && Vector3.Dot(holderCont.velocity.normalized, head.forward) > 0.86)
         {
             thrusting = true;
         }
         else
         {
             thrusting = false;
         }
     }
     if (holder != null && isPickedUp == true && stillPickedUp == true)
     {
         //Debug.DrawRay(Offhand.transform.position, Quaternion.FromToRotation(Vector3.forward, new Vector3(Offhand.GetComponent<Grabber>().Controller.GetAxis().x, 0, Offhand.GetComponent<Grabber>().Controller.GetAxis().y)) * Vector3.forward);
         if (Offhand.GetComponent <Grabber>().Controller.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad) && CanDash)
         {
             DashDir = Vector3.Normalize(Quaternion.FromToRotation(Vector3.forward, new Vector3(Offhand.GetComponent <Grabber>().Controller.GetAxis().x, 0, Offhand.GetComponent <Grabber>().Controller.GetAxis().y)) * Vector3.ProjectOnPlane(head.transform.forward, Vector3.up));
             dashing = true;
             CanDash = false;
             StartCoroutine(ExtentionMethods.Cooldown(DashDuration + DashCooldown, (x) => CanDash = x));
             StartCoroutine(ExtentionMethods.Cooldown(DashDuration, (x) => dashing = !x));
         }
         if (dashing)
         {
             head.parent.position += DashDir * DashSpeed;
         }
     }
 }
Exemple #4
0
 public void OnTriggerExit(Collider other)
 {
     if (other.tag == "PlayerWeapon")
     {
         //have a cooldwon to prevent repeat rapid cutting and other weirdness
         StartCoroutine(ExtentionMethods.Cooldown(0.1f, (x) => HasStruck = !x));
     }
 }
Exemple #5
0
 // Use this for initialization
 void Start()
 {
     StartCoroutine(ExtentionMethods.Cooldown(AttackTime, (x) => TimeOut = x));
     //Debug.Log(transform.Find("FinalBlock").GetComponent<ParticleSystem>().isEmitting);
     EndEffects    = new ParticleSystem[4];
     EndEffects[0] = transform.Find("FinalBlock").GetComponent <ParticleSystem>();
     EndEffects[1] = transform.Find("FinalFloor").GetComponent <ParticleSystem>();
     EndEffects[2] = transform.Find("FinalWave").GetComponent <ParticleSystem>();
     EndEffects[3] = transform.Find("FinalChill").GetComponent <ParticleSystem>();
 }
Exemple #6
0
    Rect reMapRect(Rect input)
    {
        Rect output = new Rect();

        output.xMin = ExtentionMethods.Remap(input.xMin, minXpicture, maxXpicture, -Cnc_Settings.WidthInMM / 2, Cnc_Settings.WidthInMM / 2);
        output.xMax = ExtentionMethods.Remap(input.xMax, minXpicture, maxXpicture, -Cnc_Settings.WidthInMM / 2, Cnc_Settings.WidthInMM / 2);

        output.yMin = ExtentionMethods.Remap(input.yMin, minYpicture, maxYpicture, Cnc_Settings.HeightInMM / 2, -Cnc_Settings.HeightInMM / 2);
        output.yMax = ExtentionMethods.Remap(input.yMax, minYpicture, maxYpicture, Cnc_Settings.HeightInMM / 2, -Cnc_Settings.HeightInMM / 2);

        return(output);
    }
Exemple #7
0
    public void Death()
    {
        stageManager.Restart();
        rig.velocity            = Vector2.zero;
        rig.simulated           = true;
        transform.localPosition = hipPositionBuffer;

        playerHip.sprite = hips[(int)PlayerState.Normal];
        isCrouching      = false;
        crouchingTime    = 0f;

#if UNITY_EDITOR
        ExtentionMethods.ClearLog();
#endif
    }
Exemple #8
0
 // Update is called once per frame
 void FixedUpdate()
 {
     if (!TimeOut)
     {
         transform.position += transform.forward * AttackSpeed;
     }
     else if (!Stopped)
     {
         Stopped = true;
         StartCoroutine(ExtentionMethods.Cooldown(10.5f, (x) => EffectsDone = x));
     }
     if (EffectsDone)
     {
         Destroy(transform.parent.gameObject);
     }
 }
Exemple #9
0
        public override async Task <ApplicationUser> FindAsync(string userName, string password)
        {
            RegexUtilities  regexUtilities = new RegexUtilities();
            ApplicationUser user           = new ApplicationUser();

            if (regexUtilities.IsValidEmail(userName))
            {
                user = await FindByEmailAsync(userName);
            }
            else if (regexUtilities.IsValidPhoneNumber(userName))
            {
                user = ExtentionMethods.FindByPhoneNumberAsync(userName);
            }

            return(await CheckPasswordAsync(user, password).WithCurrentCulture() ? user : null);
        }
Exemple #10
0
    // Update is called once per frame
    void Update()
    {
        //Behaivior Logic
        //dummy is either strafing or striking

        //if the dummy can't reach the player, it shouldn't be striking.
        if (sqrDistance > 1.2 * Mathf.Pow(restDistance, 2) && !swinging)
        {
            striking = false;
        }
        else if (!striking)
        {
            //otherwise it will strike at random. watch out!
            if (Random.Range(1L, 100L) > 99f)
            {
                //print("Striking!");
                striking = true;
                //strike a semi-random point in the player's torso area, and swing from either the left or right.
                NeckOffset = Random.Range(0.1f, 0.6f);
                leftRight  = Random.Range(-8, 10) - 1;
            }
        }
        //this allows the player to apply status effects to the dummy. more than one at a time, too. [WIP]
        string[] StateWords = State.Split(' ');
        if (StateWords[0] == "Frozen")
        {
            //if frozen, freeze!
            Frozen = true;
            StartCoroutine(ExtentionMethods.Cooldown(float.Parse(StateWords[1]), (x) => Frozen = !x)); //fancy wait statement. reusable!
            body.drag = 10000000;
            blade.GetComponent <Rigidbody>().drag = 10000000;
            State = "";
        }
        if (!Frozen && body.drag == 10000000)
        {
            //Unfreeze when coroutine triggers
            body.drag = 0;
            blade.GetComponent <Rigidbody>().drag = 0;
        }
    }
Exemple #11
0
        public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            var    userManager = context.OwinContext.GetUserManager <ApplicationUserManager>();
            string deviceId    = context.OwinContext.Get <string>("deviceId");

            ApplicationUser user = await userManager.FindAsync(context.UserName, context.Password);

            if (user == null)
            {
                context.SetError("invalid_grant", "The user name or password is incorrect.");
                return;
            }

            if (user.Id > 0 && deviceId != null)
            {
                UserLog userLog = new UserLog
                {
                    UserId   = user.Id,
                    DeviceId = deviceId
                };
                await ExtentionMethods.AddUserLogAsync(userLog);
            }

            ClaimsIdentity oAuthIdentity = await user.GenerateUserIdentityAsync(userManager,
                                                                                OAuthDefaults.AuthenticationType);

            ClaimsIdentity cookiesIdentity = await user.GenerateUserIdentityAsync(userManager,
                                                                                  CookieAuthenticationDefaults.AuthenticationType);

            //var identity = new ClaimsIdentity(context.Options.AuthenticationType);
            var claims = oAuthIdentity.Claims.Where(c => c.Type == ClaimTypes.Role);
            var roles  = Newtonsoft.Json.JsonConvert.SerializeObject(claims.Select(x => x.Value));

            AuthenticationProperties properties = CreateProperties(user.Id, user.UserName, user.ProfileImage, roles);
            AuthenticationTicket     ticket     = new AuthenticationTicket(oAuthIdentity, properties);

            context.Validated(ticket);
            context.Request.Context.Authentication.SignIn(cookiesIdentity);
        }
Exemple #12
0
    private void OnCollisionEnter2D(Collision2D other)
    {
        if (other.gameObject.tag == "Pad")
        {
            float          padhalfwidth = other.collider.bounds.extents.x;
            ContactPoint2D contact      = other.GetContact(0); //Just get the first contact point
            float          outAngle     = (contact.point.x - other.transform.position.x) / padhalfwidth * 45f;

            //Abort if it is an edge hit
            if (outAngle > 45f || outAngle < -45f)
            {
                return;
            }

            //Convert angle for use with unit circle
            outAngle = 90f - (outAngle);
            float   speed       = thisRigidbody.velocity.magnitude;
            Vector2 newVelocity = speed * ExtentionMethods.DegreeToVector2(outAngle);

            thisRigidbody.velocity = newVelocity;
        }
    }
        public async Task <IHttpActionResult> Manage(int id, UserDTO userDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Locations location = new Locations();
            var       user     = new ApplicationUser();

            //string profileImage = string.Empty;

            user = await UserManager.FindByIdAsync(id);

            if (!string.IsNullOrEmpty(userDTO.ProfileImage))
            {
                string ImageName = FileConverter.UploadFileToFileFolder(userDTO.ProfileImage, "ProfileImages");
                user.ProfileImage = ImageName;
            }

            //if (string.IsNullOrEmpty(userDTO.ProfileImage))
            //{
            //    profileImage = FileConverter.UploadFileToFileFolder(userDTO.ProfileImage, "ProfileImages");
            //}
            if (!String.IsNullOrEmpty(userDTO.UserName))
            {
                user.UserName = userDTO.UserName;
            }

            user.GenderId = userDTO.GenderId;

            if (!String.IsNullOrEmpty(userDTO.MobileNumber))
            {
                user.PhoneNumber = userDTO.MobileNumber;
            }

            if (!String.IsNullOrEmpty(userDTO.Email))
            {
                user.Email = userDTO.Email;
            }

            if (!String.IsNullOrEmpty(userDTO.Description))
            {
                user.Description = userDTO.Description;
            }

            //user.ProfileImage = profileImage;

            if (!String.IsNullOrEmpty(userDTO.Latitude) && !String.IsNullOrEmpty(userDTO.Longitude))
            {
                var point = LocationPoint.CreatePoint(Convert.ToDouble(userDTO.Latitude), Convert.ToDouble(userDTO.Longitude));
                location.LocationName      = userDTO.LocationName;
                location.LocationGeography = point;
                location.RowStatus         = true;
                location.CreatedDate       = DateTime.UtcNow;
            }

            Locations rs;
            bool      locationAvailable = ExtentionMethods.IsLocationAvalable(location.LocationName);

            if (locationAvailable != false)
            {
                rs = await ExtentionMethods.AddLocationAsync(location);

                user.LocationId = rs.LocationId;
            }
            else
            {
                rs = ExtentionMethods.FindLocationAsync(location.LocationName);
                if (rs != null)
                {
                    user.LocationId = rs.LocationId;
                }
            }

            IdentityResult result = await UserManager.UpdateAsync(user);

            if (result.Succeeded)
            {
                return(Ok(new { Code = "200", Message = "Registration Successfully ", ID = user.Id }));
            }

            if (!result.Succeeded)
            {
                return(GetErrorResult(result));
            }

            return(Ok());
        }
Exemple #14
0
    // Update is called once per frame
    void Update()
    {
        if (holder != null)
        {
            //used when sword is initially picked up (sword is inherited from grabber)
            if (isPickedUp == true && stillPickedUp == false)
            {   //Get Picked Up
                stillPickedUp = true;
                GetComponent <Rigidbody>().isKinematic = false;
                transform.position = holder.transform.TransformPoint(offset);
                transform.rotation = holder.transform.rotation * Quaternion.Euler(rotation);
                FixedJoint handjoint = AddFixedJoint();
                handjoint.connectedBody = gameObject.GetComponent <Rigidbody>();
                gameObject.layer        = 10;
                head       = holder.transform.parent.Find("Camera (eye)").transform;
                holderCont = holder.GetComponent <Grabber>().Controller;
                //Now DO Offhand

                //Find the other hand
                int sibling = holder.transform.GetSiblingIndex();
                if (sibling == 0)
                {
                    Offhand = holder.transform.parent.GetChild(1).gameObject;
                }
                else if (sibling == 1)
                {
                    Offhand = holder.transform.parent.GetChild(0).gameObject;
                }
                else
                {
                    print("that's not right...or left!");
                }

                //actually put something there
                Offhand.GetComponent <Grabber>().slave = true;
                OffPrefab.gameObject.SetActive(true);
                Offhand.GetComponent <Grabber>().HeldObject = OffPrefab;
                OffPrefab.transform.SetParent(Offhand.transform);
                OffPrefab.transform.localPosition = new Vector3(0, 0, 0);
                OffPrefab.transform.localRotation = new Quaternion(0, 0, 0, 0);
                //replace the controller model
                Offhand.transform.Find("Model").gameObject.SetActive(false);
            }
            if (isPickedUp == true)
            {   //Do every Frame while picked up
                //change trigger to reflect controller trigger
                trigger.localEulerAngles =
                    new Vector3(-90 + 18 * holder.GetComponent <Grabber>().Controller.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger).x, 0, 0);
            }
            if (isPickedUp == false && stillPickedUp == true)
            {   //Get let go
                stillPickedUp    = false;
                gameObject.layer = 9;
                holder.GetComponent <FixedJoint>().connectedBody = null;
                Destroy(holder.GetComponent <FixedJoint>());
                holder = null;
                //Do Offhand
                OffPrefab.transform.SetParent(null);
                Offhand.transform.Find("Model").gameObject.SetActive(true);
                Offhand.GetComponent <Grabber>().slave      = false;
                Offhand.GetComponent <Grabber>().HeldObject = null;
                Offhand = null;
                OffPrefab.gameObject.SetActive(false);
            }
            if (holder.GetComponent <Grabber>().Controller.GetHairTriggerDown() && system.isEmitting == false && colour != 5 && colour != 4 && colour != 1)
            {
                //TEMP activate placeholder ability
                //print("playin!!!!");
                system.Play();
            }
            else if (holder.GetComponent <Grabber>().Controller.GetHairTriggerUp() && system.isEmitting == true)
            {
                //TEMP stop activating placeholder when trigger no longer pushed down
                //print("stoppin!!!!");
                system.Stop();
            }

            //LIGHTNING CODE
            //This code activates the Lightning element Attack [WIP]
            if (colour == 4)
            {
                if (holder.GetComponent <Grabber>().Controller.GetHairTriggerDown() && !LiEffActive && (bladeSystem.isEmitting == false))
                {
                    //Lightning.Play();
                    bladeSystem.Play();
                    arcSystem.Play();
                }

                if (bladeSystem.isEmitting == true)
                {
                    //Debug.DrawRay(transform.position, head.forward);
                    //Debug.DrawRay(transform.position, transform.forward);

                    if (Vector3.Dot(head.forward, transform.forward) > 0.86 && thrusting == true)
                    {
                        //when the sword is thrust forward, the attack triggers
                        Lightning.Play();
                        LightningSound.Play();
                        arcSystem.Stop();
                        bladeSystem.Stop();
                        LiEffActive = true;
                        StartCoroutine(ExtentionMethods.Cooldown(3f, (x) => LiEffActive = !x));
                    }
                    //if (holder.GetComponent<Grabber>().Controller.GetHairTriggerUp())
                    //{
                    //    Lightning.Stop();
                    //    LightningSound.Stop();
                    //    bladeSystem.Stop();
                    //    arcSystem.Stop();
                    //    transform.Find("LightningEffBin").GetComponent<AudioSource>().Stop();
                    //}

                    RaycastHit hitdata;
                    Debug.DrawRay(transform.TransformPoint(0, 0, 1.4f), transform.TransformDirection(0, 0, 1));
                    if (Physics.Raycast(transform.TransformPoint(0, 0, 1.4f), transform.TransformDirection(0, 0, 1), out hitdata, 15))
                    {
                        Lightningmain.startLifetime = new ParticleSystem.MinMaxCurve(hitdata.distance * 0.05f + 0.05f);
                    }
                    else
                    {
                        Lightningmain.startLifetime = new ParticleSystem.MinMaxCurve(15 * 0.05f);
                    }
                    //print("Lightning Distance: " + (Lightningmain.startLifetime.constant));
                }
            }


            //ICE CODE

            if (colour == 1)
            {
                if (holder.GetComponent <Grabber>().Controller.GetHairTriggerDown() && !IceEffActive && (bladeSystem.isEmitting == false) && !IsTouchingGround)
                {
                    //attack Charging
                    bladeSystem.Play();
                    //IceChargeEff.Play();
                    //IceChargeSnowEff.Play();
                }

                if (bladeSystem.isEmitting == true)
                {
                    if (IsTouchingGround)
                    {
                        //spawn the ice wall when the sword hits the ground
                        Vector3 IceDir = Vector3.Normalize(new Vector3(transform.forward.x, 0, transform.forward.z));
                        Vector3 IcePos = new Vector3(transform.TransformPoint(0, 0, 1.376f).x, 1, transform.TransformPoint(0, 0, 1.376f).z);
                        Instantiate(IcePrefab, IcePos, Quaternion.LookRotation(IceDir, Vector3.up));
                        bladeSystem.Stop();
                        IceEffActive = true;
                        StartCoroutine(ExtentionMethods.Cooldown(5f, (x) => IceEffActive = !x));
                    }
                }
            }

            // PEIRCE CODE

            if (holder.GetComponent <Grabber>().Controller.GetHairTriggerDown() && (colour == 5))
            {     //TEMP activate ability PEIRCE 5
                if (glyph == false)
                { //do once at the start
                    glyph = true;
                    //print("playing balde anim");
                    bladeSystem.Play();
                    GlyphOuter = Instantiate(GlyphOuterPrefab, new Vector3(head.position.x, holder.transform.parent.transform.position.y + (float)0.02, head.position.z), new Quaternion(0, 0, 0, 0));
                    GlyphInner = Instantiate(GlyphInnerPrefab, new Vector3(head.position.x, holder.transform.parent.transform.position.y + (float)0.02, head.position.z), new Quaternion(0, 0, 0, 0));
                    GetComponent <AudioSource>().Play();
                }
            }
            else if (holder.GetComponent <Grabber>().Controller.GetHairTriggerUp() && glyph)
            {   //do every frame
                GlyphInner.GetComponent <GlyphScript>().destroyed = true;
                GlyphOuter.GetComponent <GlyphScript>().destroyed = true;
                glyph = false;
                bladeSystem.Stop();
                //bladeSystem.Clear();
            }
            if (glyph)
            {   //every frame while glyph from abl 5 is active
                glyphtime++;
                holder.GetComponent <Grabber>().Controller.TriggerHapticPulse((ushort)Mathf.Min(glyphtime * 10, 500));
            }

            if (holder.GetComponent <Grabber>().Controller.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad) && canTurn)
            {
                if (holder.GetComponent <Grabber>().Controller.GetAxis().x <= 0 && Mathf.Abs(holder.GetComponent <Grabber>().Controller.GetAxis().y) <= Mathf.Abs(holder.GetComponent <Grabber>().Controller.GetAxis().x))
                { //when left pressed
                  //go left?
                    transform.Find("RapierB").GetComponent <WeissCylinder>().Target += 60;
                    colour++;
                    if (colour == 6)
                    {
                        colour = 0;
                    }
                    //print("mode:" + modes[colour]);
                    sysMain.startColor = colours[colour];
                    bldMain.startColor = colours[colour];
                    //print("ColNum: " + colour + " ColourData: " + colours[colour]);
                }
                else if (holder.GetComponent <Grabber>().Controller.GetAxis().x >= 0 && Mathf.Abs(holder.GetComponent <Grabber>().Controller.GetAxis().y) <= Mathf.Abs(holder.GetComponent <Grabber>().Controller.GetAxis().x))
                { //when right pressed
                  //go right?
                    transform.Find("RapierB").GetComponent <WeissCylinder>().Target -= 60;
                    colour--;
                    if (colour == -1)
                    {
                        colour = 5;
                    }
                    //print("mode:" + modes[colour]);
                    sysMain.startColor = colours[colour];
                    bldMain.startColor = colours[colour];
                    //print("ColNum: " + colour + " ColourData: " + colours[colour]);
                }
            }
        }
    }