コード例 #1
0
    public static void boxSupport(ref float3 search, ref SupportData data, out float3 result)
    {
        float4x4 mat = data.collider.localToWorld;

        float3 size = data.collider.halfSize;
        NativeArray <float3> vertices = new NativeArray <float3>(8, Allocator.Temp);

        vertices[0] = new float3(-size.x, -size.y, -size.z);
        vertices[1] = new float3(size.x, -size.y, -size.z);
        vertices[2] = new float3(size.x, size.y, -size.z);
        vertices[3] = new float3(-size.x, size.y, -size.z);
        vertices[4] = new float3(-size.x, -size.y, size.z);
        vertices[5] = new float3(size.x, -size.y, size.z);
        vertices[6] = new float3(size.x, size.y, size.z);
        vertices[7] = new float3(-size.x, size.y, size.z);

        float3 d;
        float  maxDot = float.NegativeInfinity;

        result = float3.zero;

        for (int i = 0; i < vertices.Length; i++)
        {
            d = math.transform(mat, vertices[i]);
            float dot = math.dot(d, search);
            if (dot > maxDot)
            {
                maxDot = dot;
                result = d;
            }
        }
        vertices.Dispose();
    }
コード例 #2
0
    private void GeneratePlayerTeamPanelInfos()
    {
        GameObject           characterInfosTemp   = Instantiate(this.characterInfosPanelPrefab, this.playerTeamContainer.transform.position, this.transform.rotation, this.playerTeamContainer.transform) as GameObject;
        CharacterPanelEditor characterInfosScript = characterInfosTemp.GetComponent <CharacterPanelEditor> ();
        SummonerData         summonerScript       = T_Player.mainSummoner;

        characterInfosTemp.name             = summonerScript.summonerName;
        characterInfosScript.summonerScript = summonerScript;
        characterInfosScript.teamId         = 1;
        characterInfosScript.GenerateSummoner();

        for (int i = 0; i < T_Player.supports.Length; i++)
        {
            //print (L_Supports[j].id + " : " + L_Supports[j].supportName + " / " + T_Player.supports [i]);
            L_SupportsInTeam.Add(T_Player.supports [i]);
            GameObject           supportInfosTemp   = Instantiate(this.supportInfosPanelPrefab, this.supportTeamContainer.transform.position, this.transform.rotation, this.supportTeamContainer.transform) as GameObject;
            CharacterPanelEditor supportInfosScript = supportInfosTemp.GetComponent <CharacterPanelEditor> ();
            SupportData          supportScript      = T_Player.supports [i];

            characterInfosTemp.name          = supportScript.supportName;
            supportInfosScript.supportScript = supportScript;
            supportInfosScript.teamId        = 1;
            supportInfosScript.GenerateSupport();
        }

        if (T_Player.supports.Length < 2)
        {
            for (int i = T_Player.supports.Length; i < 2; i++)
            {
                this.AddEmptyPanel(1, 2);
            }
        }
    }
コード例 #3
0
 public CollisionPair(Entity a, SupportData aSupport, Entity b, SupportData bSupport)
 {
     this.a        = a;
     this.b        = b;
     this.aSupport = aSupport;
     this.bSupport = bSupport;
 }
コード例 #4
0
 public Data(SupportData _support)
     : this()
 {
     this.param   = _support.UnitParam;
     this.unit    = _support.Unit;
     this.support = _support;
 }
コード例 #5
0
    public static void sphereSupport(ref float3 search, ref SupportData data, out float3 result)
    {
        float3 pos    = data.pos;
        float  radius = data.collider.radius;
        float3 d      = math.normalize(search);

        result = pos + radius * math.normalize(d);
    }
コード例 #6
0
    public void GenerateSupport(int newInt)
    {
        for (int i = 0; i < CampaignManager.playerTeam.supports.Length; i++)
        {
            SupportData supportScript = CampaignManager.playerTeam.supports[i];
            GameObject  supportGO     = Instantiate(this.charactrerPanelPrefab, this.characterContainer.transform.position, this.transform.rotation, this.characterContainer.transform) as GameObject;
            supportGO.name = supportScript.supportName;
            supportGO.transform.GetChild(0).GetChild(0).GetComponent <Text> ().text   = supportScript.supportName;
            supportGO.transform.GetChild(1).GetChild(0).GetComponent <Image>().sprite = Resources.Load <Sprite> ("character_avatars/" + supportScript.idAvatar);
            supportGO.transform.GetChild(2).gameObject.SetActive(false);
            //supportGO.transform.GetChild (2).GetChild (0).GetChild (0).GetComponent<Text> ().text = supportScript.pv.ToString() + " / " + supportScript.pvMax.ToString ();
            //supportGO.transform.GetChild (2).GetChild (1).GetChild (0).GetComponent<Text> ().text = supportScript.force.ToString ();
            //supportGO.transform.GetChild (2).GetChild (2).GetChild (0).GetComponent<Text> ().text = supportScript.armure.ToString ();
            supportGO.transform.GetChild(3).GetChild(0).GetChild(0).GetComponent <Text> ().text = supportScript.nbSkillSlots.ToString();
            supportGO.transform.GetChild(3).GetChild(1).GetChild(0).GetComponent <Text> ().text = supportScript.nbDice.ToString() + " / " + supportScript.nbDiceMax.ToString();

            supportGO.GetComponent <PopupElement> ().support       = supportScript;
            supportGO.GetComponent <PopupElement> ().characterType = 2;
            supportGO.GetComponent <PopupElement> ().characterId   = i;

            if (newInt == 1)
            {
                supportGO.GetComponent <Button> ().enabled  = false;
                supportGO.GetComponent <Outline> ().enabled = false;
            }
            else
            {
                if (supportScript.nbDice == supportScript.nbDiceMax)
                {
                    supportGO.GetComponent <Button> ().enabled  = false;
                    supportGO.GetComponent <Outline> ().enabled = false;
                }
            }

            for (int j = 0; j < supportScript.nbSkillSlots; j++)
            {
                ActionsData actionTemp = DictionaryManager.GetAction(supportScript.L_skills [j]);
                GameObject  skillGO    = Instantiate(this.skillAttributionPrefab, this.transform.position, this.transform.rotation, supportGO.transform.GetChild(4)) as GameObject;

                skillGO.name = actionTemp.name;
                skillGO.transform.GetChild(1).GetChild(0).GetComponent <Image>().sprite = Resources.Load <Sprite> ("skill_icons/" + actionTemp.id);
                skillGO.transform.GetChild(2).GetChild(0).GetComponent <Image>().sprite = Resources.Load <Sprite> ("action_type_" + actionTemp.type);
                skillGO.transform.GetChild(3).GetComponent <Text> ().text = actionTemp.name;
                skillGO.GetComponent <Image> ().color                = DictionaryManager.ActionColor(actionTemp.color);
                skillGO.GetComponent <PopupElement> ().action        = actionTemp;
                skillGO.GetComponent <PopupElement> ().support       = supportScript;
                skillGO.GetComponent <PopupElement> ().characterType = 2;
                skillGO.GetComponent <PopupElement> ().characterId   = i;
                skillGO.GetComponent <PopupElement> ().teamId        = j;

                if (newInt == 2)
                {
                    skillGO.GetComponent <Button> ().enabled  = false;
                    skillGO.GetComponent <Outline> ().enabled = false;
                }
            }
        }
    }
コード例 #7
0
 private void UpdateSupport(SupportData newSupport)
 {
     for (int i = 0; i < L_SupportsInTeam.Count; i++)
     {
         if (L_SupportsInTeam [i].id == newSupport.id)
         {
             L_SupportsInTeam [i] = newSupport;
             T_Player.supports    = L_SupportsInTeam.ToArray();
         }
     }
 }
コード例 #8
0
ファイル: UiManager.cs プロジェクト: mAlfosea/diceCombo
 public void GenerateSupportPanel(SupportData newSupport, int newId)
 {
     if (newId == 0)
     {
         this.supportPanel_1.GetComponent <CharacterMapInfosPanel> ().InitSupportInfos(newSupport);
     }
     else
     {
         this.supportPanel_2.GetComponent <CharacterMapInfosPanel> ().InitSupportInfos(newSupport);
     }
 }
コード例 #9
0
 public Support(SupportData Data = null) : base(ElementType.Support)
 {
     if (Data != null)
     {
         this.Data = Data;
     }
     else
     {
         this.Data = new SupportData();
     }
 }
コード例 #10
0
    public void InitSupportInfos(SupportData newSupport)
    {
        this.support = newSupport;

        this.transform.GetChild(1).GetChild(0).GetComponent <Image>().sprite = Resources.Load <Sprite> ("character_avatars/" + newSupport.idAvatar);

        this.diceBloc.transform.GetChild(1).GetComponent <Text> ().text = newSupport.nbDice.ToString() + " / " + newSupport.nbDiceMax.ToString();

        skillPanelTargetPos.transform.position = new Vector3(20f + (60f * this.support.nbSkillSlots), skillPanelTargetPos.transform.position.y, skillPanelTargetPos.transform.position.z);

        this.GenerateSkillSlots();
    }
コード例 #11
0
        public bool DeleteVideo(string IdVideo, string Volume)
        {
            bool result = false;

            using (PikoDataContext dataContext = new PikoDataContext(PikoDataServiceApp.DatabasePath, "PikoServer"))
            {
                SupportData data = GetVideoInfo(IdVideo);
                dataContext.Execute("DELETE FROM Videos WHERE ID ='" + IdVideo + "'");
                System.IO.File.Delete(System.IO.Path.Combine(Volume, data.FileName + data.Extension));
                result = true;
            }
            return(result);
        }
コード例 #12
0
        public SupportData CreateVideo(SupportData Data)
        {
            SupportData result = Data;

            using (PikoDataContext dataContext = new PikoDataContext(PikoDataServiceApp.DatabasePath, "PikoServer"))
            {
                String sqlQuery = "INSERT INTO Videos(ID,EXTENSION,TC_START,EOM,DURATION,WIDTH,HEIGHT,FRAMERATE,AUDIO_COUNT,FILE_SIZE,FILE_NAME,STATE,SUPPORT_ID,ID_CATEGORY,TITLE)" + Environment.NewLine;
                sqlQuery += "VALUES('" + Data.UIdSupport + "','" + Data.Extension + "'," + Data.TcStart + "," + Data.Eom + "," + Data.Duration + "," + Data.Width + "," + Data.Height + "," + (int)Data.FrameRate + "," + 0 + ",'" + Data.FileSize + "','" + Data.FileName + "'," + 0 + ",'0'," + Data.IdCategory + ",'" + Data.Title + "')";
                dataContext.Execute(sqlQuery);
                result = GetVideoInfo(Data.UIdSupport);
            }
            return(result);
        }
コード例 #13
0
    public static void capsuleSupport(ref float3 search, ref SupportData data, out float3 result)
    {
        float4x4 mat     = data.collider.localToWorld;
        var      inverse = data.collider.localToWorldInverse;

        search = math.transform(inverse, search);

        float3 searchxz     = new float3(search.x, 0, search.z);
        float3 searchResult = math.normalize(searchxz) * data.collider.radius;

        searchResult.y = (search.y > 0) ? data.collider.yCap : data.collider.yBase;

        result = math.transform(mat, searchResult) + data.pos;
    }
コード例 #14
0
    public static void Support(ref float3 search, ref SupportData aData, ref SupportData bData, ref int uniqueId, out SupportPoint assignment)
    {
        float3 tempA = float3.zero, tempB = float3.zero;
        float3 negativeSearch = -search;

        switch (aData.collider.type)
        {
        case ColliderType.Box:
            boxSupport(ref negativeSearch, ref aData, out tempA);
            break;

        case ColliderType.Sphere:
            sphereSupport(ref negativeSearch, ref aData, out tempA);
            break;

        case ColliderType.Capsule:
            capsuleSupport(ref negativeSearch, ref aData, out tempA);
            break;

        case ColliderType.Plane:
            //boxSupport(ref search, ref aData, ref tempA);
            break;
        }

        switch (bData.collider.type)
        {
        case ColliderType.Box:
            boxSupport(ref search, ref bData, out tempB);
            break;

        case ColliderType.Sphere:
            sphereSupport(ref search, ref bData, out tempB);
            break;

        case ColliderType.Capsule:
            capsuleSupport(ref search, ref bData, out tempB);
            break;

        case ColliderType.Plane:
            //SupportHelper.boxSupport(ref negativeSearch, ref bData, ref tempB);
            break;
        }
        assignment          = new SupportPoint(uniqueId++);
        assignment.aSupport = tempA;
        assignment.bSupport = tempB;
        assignment.v        = tempB - tempA;
    }
コード例 #15
0
        public bool SaveVideo(string IdVideo, SupportData Data)
        {
            using (PikoDataContext dataContext = new PikoDataContext(PikoDataServiceApp.DatabasePath, "PikoServer"))
            {
                if (Data.IsExist)
                {
                    //Purge TEMPLATE_FIELD
                    String sqlQuery = "DELETE FROM TEMPLATE_FIELD_VIDEO_VALUES WHERE ID_VIDEO ='" + Data.UIdSupport + "'";
                    dataContext.Execute(sqlQuery);

                    //UPDATE
                    sqlQuery  = "UPDATE Videos SET " + Environment.NewLine;
                    sqlQuery += "ID='" + Data.UIdSupport + "'," + Environment.NewLine;
                    sqlQuery += "EXTENSION='" + Data.Extension + "'," + Environment.NewLine;
                    sqlQuery += "TC_START=" + Data.TcStart.ToString() + "," + Environment.NewLine;
                    sqlQuery += "EOM=" + Data.Eom.ToString() + "," + Environment.NewLine;
                    sqlQuery += "DURATION=" + Data.Duration.ToString() + "," + Environment.NewLine;
                    sqlQuery += "WIDTH=" + Data.Width.ToString() + "," + Environment.NewLine;
                    sqlQuery += "HEIGHT=" + Data.Height.ToString() + "," + Environment.NewLine;
                    sqlQuery += "FRAMERATE=" + (int)Data.FrameRate + "," + Environment.NewLine;
                    //sqlQuery += "AUDIO_COUNT=" + Data.AudioCount.ToString() + Environment.NewLine;
                    sqlQuery += "FILE_SIZE=" + Data.FileSize.ToString() + "," + Environment.NewLine;
                    sqlQuery += "FILE_NAME='" + Data.FileName + "'," + Environment.NewLine;
                    //sqlQuery += "STATE=" + Data.State + Environment.NewLine;
                    //sqlQuery += "SUPPORT_ID=" + Environment.NewLine;
                    sqlQuery += "TITLE='" + Data.Title + "'," + Environment.NewLine;
                    sqlQuery += "ID_CATEGORY=" + Data.IdCategory.ToString() + Environment.NewLine;
                    sqlQuery += " WHERE ID='" + IdVideo + "'";
                    dataContext.Execute(sqlQuery);
                }
                else
                {
                    //INSERT
                    CreateVideo(Data);
                }
                //INSERT NEW TEMPLATE FIELD VALUE
                foreach (TemplateFieldValueData TFData in Data.TemplateFields)
                {
                    AddTemplateFieldValueForVideo(Data.UIdSupport, Data.IdCategory, TFData);
                }
            }
            return(true);
        }
コード例 #16
0
        public VolumeData GetVolumeData(string VolumePath)
        {
            if (System.IO.Directory.Exists(VolumePath))
            {
                Piko.XML.Element.Volume volume = Piko.XML.Element.VolumeManager.LoadVolume(VolumePath);
                //volume.Data.SupportsData = volume.Supports
                List <SupportData> supportData = new List <SupportData>();
                foreach (Support sup in volume.Supports)
                {
                    SupportData data = sup.Data;
                    data = this.GetVideoInfo(sup.Data.UIdSupport);
                    if (data != null && !String.IsNullOrEmpty(data.UIdSupport))
                    {
                        sup.Data.IsExist        = true;
                        sup.Data.Title          = data.Title;
                        sup.Data.TemplateFields = data.TemplateFields;
                    }
                    else
                    {
                        sup.Data.TemplateFields = new TemplateFieldValueData[0];
                        if (string.IsNullOrEmpty(sup.Data.FileName))
                        {
                            sup.Data.FileName = "";
                        }
                        sup.Data.UIdSupport = sup.Data.FileName;
                        sup.Data.IsExist    = false;
                    }
                    if (string.IsNullOrEmpty(sup.Data.Title))
                    {
                        sup.Data.Title = "";
                    }

                    supportData.Add(sup.Data);
                }
                volume.Data.SupportsData = supportData.ToArray();
                return(volume.Data);
            }
            return(null);
        }
コード例 #17
0
        public static SupportData ConvertWCFDataSupportData(DataPikoClient.SupportData supData)
        {
            SupportData result = new SupportData();

            result.Duration       = supData.Duration;
            result.Eom            = supData.Eom;
            result.Extension      = supData.Extension;
            result.FileName       = supData.FileName;
            result.FileSize       = supData.FileSize;
            result.FrameRate      = (FrameRate)supData.FrameRate;
            result.FullPath       = supData.FullPath;
            result.Height         = supData.Height;
            result.IdCategory     = supData.Height;
            result.IsExist        = supData.IsExist;
            result.TcStart        = supData.TcStart;
            result.Title          = supData.Title;
            result.UIdSupport     = supData.UIdSupport;
            result.Width          = supData.Width;
            result.TemplateFields = new Piko.XML.Data.TemplateFieldValueData[supData.TemplateFields.Length];



            return(result);
        }
コード例 #18
0
        /// <summary>
        /// Changes the relative velocity between the character and its support.
        /// </summary>
        /// <param name="supportData">Support data to use to jump.</param>
        /// <param name="velocityChange">Change to apply to the character and support relative velocity.</param>
        /// <param name="relativeVelocity">Relative velocity to update.</param>
        void ApplyJumpVelocity(ref SupportData supportData, Vector3 velocityChange, ref Vector3 relativeVelocity)
        {

            Body.LinearVelocity += velocityChange;
            var entityCollidable = supportData.SupportObject as EntityCollidable;
            if (entityCollidable != null)
            {
                if (entityCollidable.Entity.IsDynamic)
                {
                    Vector3 change = velocityChange * jumpForceFactor;
                    entityCollidable.Entity.LinearMomentum += change * -Body.Mass;
                    velocityChange += change;
                }
            }

            //Update the relative velocity as well.  It's a ref parameter, so this update will be reflected in the calling scope.
            Vector3.Add(ref relativeVelocity, ref velocityChange, out relativeVelocity);

        }
コード例 #19
0
        void ComputeRelativeVelocity(ref SupportData supportData, out Vector3 relativeVelocity)
        {

            //Compute the relative velocity between the body and its support, if any.
            //The relative velocity will be updated as impulses are applied.
            relativeVelocity = Body.LinearVelocity;
            if (SupportFinder.HasSupport)
            {
                //Only entities has velocity.
                var entityCollidable = supportData.SupportObject as EntityCollidable;
                if (entityCollidable != null)
                {
                    Vector3 entityVelocity = Toolbox.GetVelocityOfPoint(supportData.Position, entityCollidable.Entity);
                    Vector3.Subtract(ref relativeVelocity, ref entityVelocity, out relativeVelocity);
                }
            }

        }
コード例 #20
0
        void IBeforeSolverUpdateable.Update(float dt)
        {
            bool hadTraction = SupportFinder.HasTraction;

            CollectSupportData();

            //Compute the initial velocities relative to the support.
            Vector3 relativeVelocity;
            ComputeRelativeVelocity(ref supportData, out relativeVelocity);
            float verticalVelocity = Vector3.Dot(supportData.Normal, relativeVelocity);
            Vector3 horizontalVelocity = relativeVelocity - supportData.Normal * verticalVelocity;



            //Don't attempt to use an object as support if we are flying away from it (and we were never standing on it to begin with).
            if (SupportFinder.HasTraction && !hadTraction && verticalVelocity < 0)
            {
                SupportFinder.ClearSupportData();
                supportData = new SupportData();
            }

            //If we can compute that we're separating faster than we can handle, take off.
            if (SupportFinder.HasTraction && verticalVelocity < -VerticalMotionConstraint.MaximumGlueForce * dt / VerticalMotionConstraint.EffectiveMass)
            {
                SupportFinder.ClearSupportData();
                supportData = new SupportData();
            }


            //Attempt to jump.
            if (tryToJump) //Jumping while crouching would be a bit silly.
            {
                //In the following, note that the jumping velocity changes are computed such that the separating velocity is specifically achieved,
                //rather than just adding some speed along an arbitrary direction.  This avoids some cases where the character could otherwise increase
                //the jump speed, which may not be desired.
                if (SupportFinder.HasTraction)
                {
                    //The character has traction, so jump straight up.
                    float currentUpVelocity = Vector3.Dot(Body.OrientationMatrix.Up, relativeVelocity);
                    //Target velocity is JumpSpeed.
                    float velocityChange = Math.Max(jumpSpeed - currentUpVelocity, 0);
                    ApplyJumpVelocity(ref supportData, Body.OrientationMatrix.Up * velocityChange, ref relativeVelocity);


                    //Prevent any old contacts from hanging around and coming back with a negative depth.
                    foreach (var pair in Body.CollisionInformation.Pairs)
                        pair.ClearContacts();
                    SupportFinder.ClearSupportData();
                    supportData = new SupportData();
                }
                else if (SupportFinder.HasSupport)
                {
                    //The character does not have traction, so jump along the surface normal instead.
                    float currentNormalVelocity = Vector3.Dot(supportData.Normal, relativeVelocity);
                    //Target velocity is JumpSpeed.
                    float velocityChange = Math.Max(slidingJumpSpeed - currentNormalVelocity, 0);
                    ApplyJumpVelocity(ref supportData, supportData.Normal * -velocityChange, ref relativeVelocity);

                    //Prevent any old contacts from hanging around and coming back with a negative depth.
                    foreach (var pair in Body.CollisionInformation.Pairs)
                        pair.ClearContacts();
                    SupportFinder.ClearSupportData();
                    supportData = new SupportData();
                }
            }
            tryToJump = false;


            //if (SupportFinder.HasTraction && SupportFinder.Supports.Count == 0)
            //{
            //    //There's another way to step down that is a lot cheaper, but less robust.
            //    //This modifies the velocity of the character to make it fall faster.
            //    //Impacts with the ground will be harder, so it will apply superfluous force to supports.
            //    //Additionally, it will not be consistent with instant up-stepping.
            //    //However, because it does not do any expensive queries, it is very fast!

            //    //We are being supported by a ray cast, but we're floating.
            //    //Let's try to get to the ground faster.
            //    //How fast?  Try picking an arbitrary velocity and setting our relative vertical velocity to that value.
            //    //Don't go farther than the maximum distance, though.
            //    float maxVelocity = (SupportFinder.SupportRayData.Value.HitData.T - SupportFinder.RayLengthToBottom);
            //    if (maxVelocity > 0)
            //    {
            //        maxVelocity = (maxVelocity + .01f) / dt;

            //        float targetVerticalVelocity = -3;
            //        verticalVelocity = Vector3.Dot(Body.OrientationMatrix.Up, relativeVelocity);
            //        float change = MathHelper.Clamp(targetVerticalVelocity - verticalVelocity, -maxVelocity, 0);
            //        ChangeVelocityUnilaterally(Body.OrientationMatrix.Up * change, ref relativeVelocity);
            //    }
            //}





            //Vertical support data is different because it has the capacity to stop the character from moving unless
            //contacts are pruned appropriately.
            SupportData verticalSupportData;
            Vector3 movement3d = new Vector3(HorizontalMotionConstraint.MovementDirection.X, 0, HorizontalMotionConstraint.MovementDirection.Y);
            SupportFinder.GetTractionInDirection(ref movement3d, out verticalSupportData);


            //Warning:
            //Changing a constraint's support data is not thread safe; it modifies simulation islands!
            //If something other than the SphereCharacterController can modify simulation islands is running
            //simultaneously (in the IBeforeSolverUpdateable.Update stage), it will need to be synchronized.
            ConstraintAccessLocker.Enter();
            HorizontalMotionConstraint.SupportData = supportData;
            VerticalMotionConstraint.SupportData = verticalSupportData;
            ConstraintAccessLocker.Exit();






        }
コード例 #21
0
        void CollectSupportData()
        {
            //Identify supports.
            SupportFinder.UpdateSupports();

            //Collect the support data from the support, if any.
            if (SupportFinder.HasSupport)
            {
                if (SupportFinder.HasTraction)
                    supportData = SupportFinder.TractionData.Value;
                else
                    supportData = SupportFinder.SupportData.Value;
            }
            else
                supportData = new SupportData();
        }
コード例 #22
0
        void IBeforeSolverUpdateable.Update(float dt)
        {
            //Someone may want to use the Body.CollisionInformation.Tag for their own purposes.
            //That could screw up the locking mechanism above and would be tricky to track down.
            //Consider using the making the custom tag implement ICharacterTag, modifying LockCharacterPairs to analyze the different Tag type, or using the Entity.Tag for the custom data instead.
            Debug.Assert(Body.CollisionInformation.Tag is ICharacterTag, "The character.Body.CollisionInformation.Tag must implement ICharacterTag to link the SphereCharacterController and its body together for character-related locking to work in multithreaded simulations.");

            //We can't let multiple characters manage the same pairs simultaneously.  Lock it up!
            LockCharacterPairs();
            try
            {
                bool hadTraction = SupportFinder.HasTraction;

                CollectSupportData();

                //Compute the initial velocities relative to the support.
                Vector3 relativeVelocity;
                ComputeRelativeVelocity(ref supportData, out relativeVelocity);
                float verticalVelocity = Vector3.Dot(supportData.Normal, relativeVelocity);

                //Don't attempt to use an object as support if we are flying away from it (and we were never standing on it to begin with).
                if (SupportFinder.HasTraction && !hadTraction && verticalVelocity < 0)
                {
                    SupportFinder.ClearSupportData();
                    supportData = new SupportData();
                }

                //Attempt to jump.
                if (tryToJump) //Jumping while crouching would be a bit silly.
                {
                    //In the following, note that the jumping velocity changes are computed such that the separating velocity is specifically achieved,
                    //rather than just adding some speed along an arbitrary direction.  This avoids some cases where the character could otherwise increase
                    //the jump speed, which may not be desired.
                    if (SupportFinder.HasTraction)
                    {
                        //The character has traction, so jump straight up.
                        float currentUpVelocity = Vector3.Dot(Body.OrientationMatrix.Up, relativeVelocity);
                        //Target velocity is JumpSpeed.
                        float velocityChange;
                        velocityChange = Math.Max(jumpSpeed - currentUpVelocity, 0);

                        ApplyJumpVelocity(ref supportData, Body.OrientationMatrix.Up * velocityChange, ref relativeVelocity);

                        //Prevent any old contacts from hanging around and coming back with a negative depth.
                        foreach (var pair in Body.CollisionInformation.Pairs)
                            pair.ClearContacts();
                        SupportFinder.ClearSupportData();
                        supportData = new SupportData();
                    }
                    else if (SupportFinder.HasSupport)
                    {
                        //The character does not have traction, so jump along the surface normal instead.
                        float currentNormalVelocity = Vector3.Dot(supportData.Normal, relativeVelocity);
                        //Target velocity is JumpSpeed.
                        float velocityChange = Math.Max(slidingJumpSpeed - currentNormalVelocity, 0);
                        ApplyJumpVelocity(ref supportData, supportData.Normal * -velocityChange, ref relativeVelocity);

                        //Prevent any old contacts from hanging around and coming back with a negative depth.
                        foreach (var pair in Body.CollisionInformation.Pairs)
                            pair.ClearContacts();
                        SupportFinder.ClearSupportData();
                        supportData = new SupportData();
                    }
                }
                tryToJump = false;
            }
            finally
            {
                UnlockCharacterPairs();
            }

            //Vertical support data is different because it has the capacity to stop the character from moving unless
            //contacts are pruned appropriately.
            SupportData verticalSupportData;
            Vector3 movement3d = new Vector3(HorizontalMotionConstraint.MovementDirection.X, 0, HorizontalMotionConstraint.MovementDirection.Y);
            SupportFinder.GetTractionInDirection(ref movement3d, out verticalSupportData);

            //Warning:
            //Changing a constraint's support data is not thread safe; it modifies simulation islands!
            //If something other than a CharacterController can modify simulation islands is running
            //simultaneously (in the IBeforeSolverUpdateable.Update stage), it will need to be synchronized.

            //We don't need to synchronize this all the time- only when the support object changes.
            bool needToLock = HorizontalMotionConstraint.SupportData.SupportObject != supportData.SupportObject ||
                              VerticalMotionConstraint.SupportData.SupportObject != verticalSupportData.SupportObject;

            if (needToLock)
                CharacterSynchronizer.ConstraintAccessLocker.Enter();

            HorizontalMotionConstraint.SupportData = supportData;
            VerticalMotionConstraint.SupportData = verticalSupportData;

            if (needToLock)
                CharacterSynchronizer.ConstraintAccessLocker.Exit();
        }
コード例 #23
0
        void IBeforeSolverUpdateable.Update(float dt)
        {
            //Someone may want to use the Body.CollisionInformation.Tag for their own purposes.
            //That could screw up the locking mechanism above and would be tricky to track down.
            //Consider using the making the custom tag implement ICharacterTag, modifying LockCharacterPairs to analyze the different Tag type, or using the Entity.Tag for the custom data instead.
            Debug.Assert(Body.CollisionInformation.Tag is ICharacterTag, "The character.Body.CollisionInformation.Tag must implement ICharacterTag to link the CharacterController and its body together for character-related locking to work in multithreaded simulations.");

            //We can't let multiple characters manage the same pairs simultaneously.  Lock it up!
            LockCharacterPairs();
            try
            {
                CorrectContacts();

                bool hadTraction = SupportFinder.HasTraction;

                CollectSupportData();

                //Compute the initial velocities relative to the support.
                Vector3 relativeVelocity;
                ComputeRelativeVelocity(ref supportData, out relativeVelocity);
                float verticalVelocity = Vector3.Dot(supportData.Normal, relativeVelocity);

                //Don't attempt to use an object as support if we are flying away from it (and we were never standing on it to begin with).
                if (SupportFinder.HasTraction && !hadTraction && verticalVelocity < 0)
                {
                    SupportFinder.ClearSupportData();
                    supportData = new SupportData();
                }

                //Attempt to jump.
                if (tryToJump && StanceManager.CurrentStance != Stance.Crouching) //Jumping while crouching would be a bit silly.
                {
                    //In the following, note that the jumping velocity changes are computed such that the separating velocity is specifically achieved,
                    //rather than just adding some speed along an arbitrary direction.  This avoids some cases where the character could otherwise increase
                    //the jump speed, which may not be desired.
                    if (SupportFinder.HasTraction)
                    {
                        //The character has traction, so jump straight up.
                        float currentUpVelocity = Vector3.Dot(Body.OrientationMatrix.Up, relativeVelocity);
                        //Target velocity is JumpSpeed.
                        float velocityChange = Math.Max(jumpSpeed - currentUpVelocity, 0);
                        ApplyJumpVelocity(ref supportData, Body.OrientationMatrix.Up * velocityChange, ref relativeVelocity);

                        //Prevent any old contacts from hanging around and coming back with a negative depth.
                        foreach (var pair in Body.CollisionInformation.Pairs)
                            pair.ClearContacts();
                        SupportFinder.ClearSupportData();
                        supportData = new SupportData();
                    }
                    else if (SupportFinder.HasSupport)
                    {
                        //The character does not have traction, so jump along the surface normal instead.
                        float currentNormalVelocity = Vector3.Dot(supportData.Normal, relativeVelocity);
                        //Target velocity is JumpSpeed.
                        float velocityChange = Math.Max(slidingJumpSpeed - currentNormalVelocity, 0);
                        ApplyJumpVelocity(ref supportData, supportData.Normal * -velocityChange, ref relativeVelocity);

                        //Prevent any old contacts from hanging around and coming back with a negative depth.
                        foreach (var pair in Body.CollisionInformation.Pairs)
                            pair.ClearContacts();
                        SupportFinder.ClearSupportData();
                        supportData = new SupportData();
                    }
                }
                tryToJump = false;

                //Try to step!
                Vector3 newPosition;
                if (StepManager.TryToStepDown(out newPosition) ||
                    StepManager.TryToStepUp(out newPosition))
                {
                    TeleportToPosition(newPosition, dt);
                }

                if (StanceManager.UpdateStance(out newPosition))
                {
                    TeleportToPosition(newPosition, dt);
                }
            }
            finally
            {
                UnlockCharacterPairs();
            }

            //if (SupportFinder.HasTraction && SupportFinder.Supports.Count == 0)
            //{
            //There's another way to step down that is a lot cheaper, but less robust.
            //This modifies the velocity of the character to make it fall faster.
            //Impacts with the ground will be harder, so it will apply superfluous force to supports.
            //Additionally, it will not be consistent with instant up-stepping.
            //However, because it does not do any expensive queries, it is very fast!

            ////We are being supported by a ray cast, but we're floating.
            ////Let's try to get to the ground faster.
            ////How fast?  Try picking an arbitrary velocity and setting our relative vertical velocity to that value.
            ////Don't go farther than the maximum distance, though.
            //float maxVelocity = (SupportFinder.SupportRayData.Value.HitData.T - SupportFinder.RayLengthToBottom);
            //if (maxVelocity > 0)
            //{
            //    maxVelocity = (maxVelocity + .01f) / dt;

            //    float targetVerticalVelocity = -3;
            //    verticalVelocity = Vector3.Dot(Body.OrientationMatrix.Up, relativeVelocity);
            //    float change = MathHelper.Clamp(targetVerticalVelocity - verticalVelocity, -maxVelocity, 0);
            //    ChangeVelocityUnilaterally(Body.OrientationMatrix.Up * change, ref relativeVelocity);
            //}
            //}

            //Vertical support data is different because it has the capacity to stop the character from moving unless
            //contacts are pruned appropriately.
            SupportData verticalSupportData;
            Vector3 movement3d = new Vector3(HorizontalMotionConstraint.MovementDirection.X, 0, HorizontalMotionConstraint.MovementDirection.Y);
            SupportFinder.GetTractionInDirection(ref movement3d, out verticalSupportData);

            //Warning:
            //Changing a constraint's support data is not thread safe; it modifies simulation islands!
            //If something other than a CharacterController can modify simulation islands is running
            //simultaneously (in the IBeforeSolverUpdateable.Update stage), it will need to be synchronized.

            //We don't need to synchronize this all the time- only when the support object changes.
            bool needToLock = HorizontalMotionConstraint.SupportData.SupportObject != supportData.SupportObject ||
                              VerticalMotionConstraint.SupportData.SupportObject != verticalSupportData.SupportObject;

            if (needToLock)
                CharacterSynchronizer.ConstraintAccessLocker.Enter();

            HorizontalMotionConstraint.SupportData = supportData;
            VerticalMotionConstraint.SupportData = verticalSupportData;

            if (needToLock)
                CharacterSynchronizer.ConstraintAccessLocker.Exit();
        }
コード例 #24
0
 public static bool validSupport(ref SupportData aData, ref SupportData bData)
 {
     return(aData.collider.type != ColliderType.Other && bData.collider.type != ColliderType.Other);
 }
コード例 #25
0
 /// <summary>
 /// 获取所有兴趣组列表
 /// </summary>
 /// <returns></returns>
 public static IEnumerable <InterestWordInfo> GetInterestWords()
 {
     return(SupportData.GetInterestWords());
 }
コード例 #26
0
    public void ChangeCharacter(int newTeamId, int newCharacterType, int newCharacterId, int newCharacterIndex, int newCharacterIdToAdd)
    {
        if (newCharacterType == 1)
        {
            for (int j = 0; j < this.playerTeamContainer.transform.childCount; j++)
            {
                CharacterPanelEditor characterInfosScript = this.playerTeamContainer.transform.GetChild(j).GetComponent <CharacterPanelEditor> ();
                if (characterInfosScript.summonerScript.id == newCharacterId)
                {
                    Destroy(this.playerTeamContainer.transform.GetChild(j).gameObject);

                    for (int k = 0; k < L_Summoners.Count; k++)
                    {
                        if (L_Summoners [k].id == newCharacterIdToAdd)
                        {
                            T_Player.mainSummoner = L_Summoners [k];

                            GameObject           characterInfosTemp       = Instantiate(this.characterInfosPanelPrefab, this.playerTeamContainer.transform.position, this.transform.rotation, this.playerTeamContainer.transform) as GameObject;
                            CharacterPanelEditor characterInfosScriptTemp = characterInfosTemp.GetComponent <CharacterPanelEditor> ();
                            SummonerData         summonerScript           = L_Summoners [k];

                            characterInfosTemp.transform.SetSiblingIndex(j);
                            characterInfosTemp.name = summonerScript.summonerName;
                            characterInfosScriptTemp.summonerScript = summonerScript;
                            characterInfosScriptTemp.teamId         = 1;
                            characterInfosScriptTemp.GenerateSummoner();
                            return;
                        }
                    }
                }
            }
        }
        else if (newCharacterType == 2)
        {
            for (int i = 0; i < L_SupportsInTeam.Count; i++)
            {
                if (L_SupportsInTeam [i].id == newCharacterId)
                {
                    for (int j = 0; j < this.supportTeamContainer.transform.childCount; j++)
                    {
                        CharacterPanelEditor characterInfosScript = this.supportTeamContainer.transform.GetChild(j).GetComponent <CharacterPanelEditor> ();
                        if (characterInfosScript.supportScript.id == newCharacterId)
                        {
                            Destroy(this.supportTeamContainer.transform.GetChild(j).gameObject);

                            for (int k = 0; k < L_Supports.Count; k++)
                            {
                                if (L_Supports [k].id == newCharacterIdToAdd)
                                {
                                    GameObject           characterInfosTemp       = Instantiate(this.supportInfosPanelPrefab, this.supportTeamContainer.transform.position, this.transform.rotation, this.supportTeamContainer.transform) as GameObject;
                                    CharacterPanelEditor characterInfosScriptTemp = characterInfosTemp.GetComponent <CharacterPanelEditor> ();
                                    SupportData          supportScript            = L_Supports [k];

                                    characterInfosTemp.transform.SetSiblingIndex(i);
                                    characterInfosTemp.name = supportScript.supportName;
                                    characterInfosScriptTemp.supportScript = supportScript;
                                    characterInfosScriptTemp.teamId        = 1;
                                    characterInfosScriptTemp.GenerateSupport();

                                    L_SupportsInTeam [i] = L_Supports [k];
                                    T_Player.supports    = L_SupportsInTeam.ToArray();

                                    return;
                                }
                            }
                        }
                    }
                }
            }
            int index = 0;

            for (int j = 0; j < this.supportTeamContainer.transform.childCount; j++)
            {
                CharacterPanelEditor characterInfosScript = this.supportTeamContainer.transform.GetChild(j).GetComponent <CharacterPanelEditor> ();
                print(characterInfosScript.supportScript.id + " / " + newCharacterId);
                if (characterInfosScript.supportScript.id == newCharacterId)
                {
                    index = j;
                    Destroy(this.supportTeamContainer.transform.GetChild(j).gameObject);

                    break;
                }
            }

            for (int i = 0; i < L_Supports.Count; i++)
            {
                if (L_Supports [i].id == newCharacterIdToAdd)
                {
                    GameObject           characterInfosTemp   = Instantiate(this.supportInfosPanelPrefab, this.supportTeamContainer.transform.position, this.transform.rotation, this.supportTeamContainer.transform) as GameObject;
                    CharacterPanelEditor characterInfosScript = characterInfosTemp.GetComponent <CharacterPanelEditor> ();
                    SupportData          supportScript        = L_Supports [i];

                    characterInfosTemp.transform.SetSiblingIndex(index);
                    characterInfosTemp.name            = supportScript.supportName;
                    characterInfosScript.supportScript = supportScript;
                    characterInfosScript.teamId        = 1;
                    characterInfosScript.GenerateSupport();

                    L_SupportsInTeam.Add(L_Supports [i]);
                    T_Player.supports = L_SupportsInTeam.ToArray();

                    return;
                }
            }
        }
        else
        {
            for (int i = 0; i < L_EnemiesInTeam.Count; i++)
            {
                if (L_EnemiesInTeam [i].id == newCharacterId)
                {
                    for (int j = 0; j < this.enemyTeamContainer.transform.childCount; j++)
                    {
                        CharacterPanelEditor characterInfosScript = this.enemyTeamContainer.transform.GetChild(j).GetComponent <CharacterPanelEditor> ();
                        if (characterInfosScript.summonerScript.id == newCharacterId)
                        {
                            Destroy(this.enemyTeamContainer.transform.GetChild(j).gameObject);

                            for (int k = 0; k < L_Enemies.Count; k++)
                            {
                                if (L_Enemies [k].id == newCharacterIdToAdd)
                                {
                                    GameObject           characterInfosTemp       = Instantiate(this.characterInfosPanelPrefab, this.enemyTeamContainer.transform.position, this.transform.rotation, this.enemyTeamContainer.transform) as GameObject;
                                    CharacterPanelEditor characterInfosScriptTemp = characterInfosTemp.GetComponent <CharacterPanelEditor> ();
                                    SummonerData         summonerScript           = L_Enemies [k];

                                    characterInfosTemp.transform.SetSiblingIndex(i);
                                    characterInfosTemp.name = summonerScript.summonerName;
                                    characterInfosScriptTemp.summonerScript = summonerScript;
                                    characterInfosScriptTemp.teamId         = 2;
                                    characterInfosScriptTemp.GenerateSummoner();

                                    L_EnemiesInTeam [i] = L_Enemies [k];
                                    T_Enemy.enemies     = L_EnemiesInTeam.ToArray();

                                    return;
                                }
                            }
                        }
                    }
                }
            }
            int index = 0;

            for (int j = 0; j < this.enemyTeamContainer.transform.childCount; j++)
            {
                CharacterPanelEditor characterInfosScript = this.enemyTeamContainer.transform.GetChild(j).GetComponent <CharacterPanelEditor> ();
                print(characterInfosScript.summonerScript.id + " / " + newCharacterId);
                if (characterInfosScript.summonerScript.id == newCharacterId)
                {
                    index = j;
                    Destroy(this.enemyTeamContainer.transform.GetChild(j).gameObject);

                    break;
                }
            }

            for (int i = 0; i < L_Enemies.Count; i++)
            {
                if (L_Enemies [i].id == newCharacterIdToAdd)
                {
                    GameObject           characterInfosTemp   = Instantiate(this.characterInfosPanelPrefab, this.enemyTeamContainer.transform.position, this.transform.rotation, this.enemyTeamContainer.transform) as GameObject;
                    CharacterPanelEditor characterInfosScript = characterInfosTemp.GetComponent <CharacterPanelEditor> ();
                    SummonerData         summonerScript       = L_Enemies [i];

                    characterInfosTemp.transform.SetSiblingIndex(index);
                    characterInfosTemp.name             = summonerScript.summonerName;
                    characterInfosScript.summonerScript = summonerScript;
                    characterInfosScript.teamId         = 2;
                    characterInfosScript.GenerateSummoner();

                    L_EnemiesInTeam.Add(L_Enemies [i]);
                    T_Enemy.enemies = L_EnemiesInTeam.ToArray();

                    return;
                }
            }
        }
    }
コード例 #27
0
 /// <summary>
 /// 注册用户设备信息
 /// </summary>
 /// <param name="device"></param>
 public static void RegisterDevice(UserDevice device)
 {
     SupportData.RegisterDevice(device);
 }
コード例 #28
0
 public void ClearSupportData()
 {
     SupportFinder.ClearSupportData();
     supportData = new SupportData();
 }
コード例 #29
0
        public SupportData GetVideoInfo(string IdVideo)
        {
            SupportData videoInfo = null;

            try
            {
                using (PikoDataContext dataContext = new PikoDataContext(PikoDataServiceApp.DatabasePath, "PikoServer"))
                {
                    String          sqlQuery = "SELECT ID, EXTENSION,TC_START,EOM,DURATION,WIDTH,HEIGHT,FRAMERATE,AUDIO_COUNT,FILE_SIZE,FILE_NAME,STATE,SUPPORT_ID,ID_CATEGORY,TITLE FROM Videos WHERE Id = '" + IdVideo + "'";
                    OleDbDataReader result   = dataContext.Select(sqlQuery);
                    if (result.HasRows)
                    {
                        if (result.Read())
                        {
                            videoInfo = new SupportData();
                            int idxColumn = result.GetOrdinal("ID");
                            videoInfo.UIdSupport = result.GetString(idxColumn);
                            if (videoInfo.UIdSupport == null)
                            {
                                videoInfo.UIdSupport = IdVideo;
                            }
                            idxColumn           = result.GetOrdinal("EXTENSION");
                            videoInfo.Extension = result.GetString(idxColumn);
                            if (videoInfo.Extension == null)
                            {
                                videoInfo.Extension = "";
                            }
                            idxColumn          = result.GetOrdinal("TC_START");
                            videoInfo.TcStart  = (ulong)result.GetInt32(idxColumn);
                            idxColumn          = result.GetOrdinal("FILE_NAME");
                            videoInfo.FileName = result.GetString(idxColumn);
                            if (videoInfo.FileName == null)
                            {
                                videoInfo.FileName = "";
                            }
                            videoInfo.IsExist    = true;
                            idxColumn            = result.GetOrdinal("FILE_SIZE");
                            videoInfo.FileSize   = long.Parse(result.GetString(idxColumn));
                            idxColumn            = result.GetOrdinal("ID_CATEGORY");
                            videoInfo.IdCategory = result.GetInt32(idxColumn);
                            videoInfo.FullPath   = videoInfo.FileName + videoInfo.Extension;
                            idxColumn            = result.GetOrdinal("TITLE");
                            videoInfo.Title      = result.GetString(idxColumn);

                            result.Close();

                            sqlQuery  = "SELECT TFC.ID, TFC.ID_TEMPLATE_FIELD, TF.LABEL AS LABEL_TEMPLATE_FIELD,TF.ID_FIELD_TYPE " + Environment.NewLine;
                            sqlQuery += "FROM TEMPLATE_FIELD AS TF " + Environment.NewLine + "INNER JOIN TEMPLATE_FIELD_CATEGORY AS TFC ON TF.ID = TFC.ID_TEMPLATE_FIELD " + Environment.NewLine;
                            sqlQuery += "WHERE ID_CATEGORY = " + videoInfo.IdCategory.ToString();
                            //sqlQuery += "LEFT JOIN TEMPLATE_FIELD_VIDEO_VALUES AS TFVV ON TFC.ID = TFVV.ID_TEMPLATE_FIELD " + Environment.NewLine;
                            //sqlQuery += "WHERE TFVV.ID_VIDEO = '" + IdVideo + "' AND ID_CATEGORY = " + videoInfo.IdCategory.ToString();
                            result = dataContext.Select(sqlQuery);
                            if (result.HasRows)
                            {
                                List <TemplateFieldValueData> listTFData = new List <TemplateFieldValueData>();
                                while (result.Read())
                                {
                                    idxColumn = result.GetOrdinal("ID");
                                    int idTfc = result.GetInt32(idxColumn);
                                    //TFVV.ID AS ID_VALUE,TFVV.VALUE,TFVV.ID_VIDEO
                                    string sqlQuery2 = "SELECT ID,FIELD_VALUE,ID_VIDEO " + Environment.NewLine;
                                    sqlQuery2 += "FROM TEMPLATE_FIELD_VIDEO_VALUES " + Environment.NewLine;
                                    sqlQuery2 += "WHERE ID_VIDEO = '" + IdVideo + "' AND ID_TEMPLATE_FIELD_CATEGORY = " + idTfc.ToString();

                                    OleDbDataReader        result2     = dataContext.Select(sqlQuery2);
                                    TemplateFieldValueData tfValueData = new TemplateFieldValueData();
                                    //FIELD DEFINITION
                                    tfValueData.FieldDefinition = new TemplateFieldData();
                                    idxColumn = result.GetOrdinal("ID");
                                    tfValueData.FieldDefinition.Id = result.GetInt32(idxColumn);
                                    tfValueData.FieldDefinition.IdFieldCategory = idTfc;
                                    idxColumn = result.GetOrdinal("LABEL_TEMPLATE_FIELD");
                                    tfValueData.FieldDefinition.FieldName = result.GetString(idxColumn);
                                    idxColumn = result.GetOrdinal("ID_FIELD_TYPE");
                                    tfValueData.FieldDefinition.FieldType = (TemplateFieldType)result.GetInt32(idxColumn);
                                    if (result2.HasRows && result2.Read())
                                    {
                                        //VALUE
                                        idxColumn         = result2.GetOrdinal("FIELD_VALUE");
                                        tfValueData.Value = result2.GetString(idxColumn);
                                    }
                                    else
                                    {
                                        tfValueData.Value = "";
                                    }
                                    result2.Close();
                                    listTFData.Add(tfValueData);
                                }
                                videoInfo.TemplateFields = listTFData.ToArray();
                            }
                            else
                            {
                                videoInfo.TemplateFields = new TemplateFieldValueData[0];
                            }
                            result.Close();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            if (videoInfo == null)
            {
                videoInfo = new SupportData();
                videoInfo.TemplateFields = new TemplateFieldValueData[0];
                videoInfo.FullPath       = "";
                videoInfo.Title          = "";
                videoInfo.FileName       = "";
                videoInfo.Extension      = "";
                videoInfo.UIdSupport     = "";
            }
            return(videoInfo);
        }
コード例 #30
0
        /// <summary>
        /// Changes the relative velocity between the character and its support.
        /// </summary>
        /// <param name="supportData">Support data to use to jump.</param>
        /// <param name="velocityChange">Change to apply to the character and support relative velocity.</param>
        /// <param name="relativeVelocity">Relative velocity to update.</param>
        void ApplyJumpVelocity(ref SupportData supportData, Vector3 velocityChange, ref Vector3 relativeVelocity)
        {
            Body.LinearVelocity += velocityChange;
            var entityCollidable = supportData.SupportObject as EntityCollidable;
            if (entityCollidable != null)
            {
                if (entityCollidable.Entity.IsDynamic)
                {
                    Vector3 change = velocityChange * jumpForceFactor;
                    //Multiple characters cannot attempt to modify another entity's velocity at the same time.
                    entityCollidable.Entity.Locker.Enter();
                    try
                    {
                        entityCollidable.Entity.LinearMomentum += change * -Body.Mass;
                    }
                    finally
                    {
                        entityCollidable.Entity.Locker.Exit();
                    }
                    velocityChange += change;
                }
            }

            //Update the relative velocity as well.  It's a ref parameter, so this update will be reflected in the calling scope.
            Vector3.Add(ref relativeVelocity, ref velocityChange, out relativeVelocity);
        }
コード例 #31
0
 /// <summary>
 /// 更新设备授权码
 /// </summary>
 /// <param name="device"></param>
 public static void SetDeviceToken(UserDevice device)
 {
     SupportData.SetDeviceToken(device);
 }
コード例 #32
0
 void ComputeRelativeVelocity(ref SupportData supportData, out Vector3 relativeVelocity)
 {
     //Compute the relative velocity between the body and its support, if any.
     //The relative velocity will be updated as impulses are applied.
     relativeVelocity = Body.LinearVelocity;
     if (SupportFinder.HasSupport)
     {
         //Only entities have velocity.
         var entityCollidable = supportData.SupportObject as EntityCollidable;
         if (entityCollidable != null)
         {
             //It's possible for the support's velocity to change due to another character jumping if the support is dynamic.
             //Don't let that happen while the character is computing a relative velocity!
             Vector3 entityVelocity;
             bool locked;
             if (locked = entityCollidable.Entity.IsDynamic)
                 entityCollidable.Entity.Locker.Enter();
             try
             {
                 entityVelocity = Toolbox.GetVelocityOfPoint(supportData.Position, entityCollidable.Entity);
             }
             finally
             {
                 if (locked)
                     entityCollidable.Entity.Locker.Exit();
             }
             Vector3.Subtract(ref relativeVelocity, ref entityVelocity, out relativeVelocity);
         }
     }
 }
コード例 #33
0
 /// <summary>
 /// 获取下一个版本信息
 /// </summary>
 /// <param name="channelCode">渠道标识码</param>
 /// <param name="currentVerName">当前版本号</param>
 /// <returns>下一个版本信息</returns>
 public static AppVersionInfo GetNextVersion(string channelCode, string currentVerName)
 {
     return(SupportData.GetNextVersion(channelCode, currentVerName));
 }
コード例 #34
0
        public ReqTowerBtlComEnd(long btlid, Unit[] Player, Unit[] Enemy, int actCount, int round, byte floor, BtlResultTypes result, RandDeckResult[] deck, string trophyprog = null, string bingoprog = null, string maxdata = null)
        {
            StringBuilder stringBuilder = WebAPI.GetStringBuilder();

            this.name            = "tower/btl/end";
            stringBuilder.Length = 0;
            this.SetValue(ref stringBuilder, "\"btlid\":", btlid);
            stringBuilder.Append("\"btlendparam\":{");
            if (Player != null)
            {
                stringBuilder.Append("\"pdeck\":[");
                for (int i = 0; i < Player.Length; i++)
                {
                    Unit unit = Player[i];
                    if (unit.Side == EUnitSide.Player && unit.UnitData.UniqueID != 0L)
                    {
                        stringBuilder.Append("{");
                        this.SetValue(ref stringBuilder, "\"iid\":", unit.UnitData.UniqueID);
                        this.SetValue(ref stringBuilder, "\"iname\":\"", unit.UnitData.UnitParam.iname, "\",");
                        int             num             = unit.CalcTowerDamege();
                        TowerFloorParam towerFloorParam = GameManager.Instance.FindTowerFloor(SceneBattle.Instance.Battle.QuestID);
                        num -= towerFloorParam.CalcHelaNum(unit.MaximumStatus.param.hp);
                        num  = Math.Max(num, 0);
                        this.SetValue(ref stringBuilder, "\"damage\":", (long)num);
                        this.SetValue(ref stringBuilder, "\"is_died\":", (!unit.IsDeadCondition()) ? 0L : 1L, string.Empty);
                        stringBuilder.Append("},");
                    }
                }
                stringBuilder.Length--;
                stringBuilder.Append("],");
            }
            stringBuilder.Append("\"status\":\"");
            switch (result)
            {
            case BtlResultTypes.Win:
                stringBuilder.Append("win");
                break;

            case BtlResultTypes.Lose:
                stringBuilder.Append("lose");
                break;

            case BtlResultTypes.Retire:
                stringBuilder.Append("retire");
                break;

            case BtlResultTypes.Cancel:
                stringBuilder.Append("cancel");
                break;
            }
            stringBuilder.Append("\"");
            stringBuilder.Append(",\"turn\":");
            stringBuilder.Append(actCount);
            stringBuilder.Append(",\"round\":");
            stringBuilder.Append(round);
            stringBuilder.Append(",\"floor\":");
            stringBuilder.Append(floor);
            if (result == BtlResultTypes.Lose)
            {
                stringBuilder.Append(",\"edeck\":[");
                List <Unit> list = new List <Unit>(Enemy);
                list.RemoveAll((Unit x) => x.Side != EUnitSide.Enemy);
                if (GameManager.Instance.TowerResuponse.edeck != null)
                {
                    List <TowerResuponse.EnemyUnit> edeck = GameManager.Instance.TowerResuponse.edeck;
                    int num2 = 0;
                    for (int j = 0; j < edeck.Count; j++)
                    {
                        if (edeck[j].hp == 0)
                        {
                            stringBuilder.Append("{");
                            this.SetValue(ref stringBuilder, "\"eid\":\"", (long)j, "\",");
                            this.SetValue(ref stringBuilder, "\"iname\":\"", edeck[j].iname, "\",");
                            this.SetValue(ref stringBuilder, "\"hp\":", 0L);
                            this.SetValue(ref stringBuilder, "\"jewel\":", 0L, string.Empty);
                            stringBuilder.Append("},");
                        }
                        else
                        {
                            Unit unit2 = list[num2];
                            num2++;
                            if (unit2.Side == EUnitSide.Enemy)
                            {
                                stringBuilder.Append("{");
                                this.SetValue(ref stringBuilder, "\"eid\":\"", (long)j, "\",");
                                this.SetValue(ref stringBuilder, "\"iname\":\"", unit2.UnitParam.iname, "\",");
                                this.SetValue(ref stringBuilder, "\"hp\":", (!unit2.IsDead) ? ((long)unit2.CurrentStatus.param.hp) : 0L);
                                this.SetValue(ref stringBuilder, "\"jewel\":", (long)unit2.CurrentStatus.param.mp, string.Empty);
                                stringBuilder.Append("},");
                            }
                        }
                    }
                }
                else
                {
                    for (int k = 0; k < list.Count; k++)
                    {
                        Unit unit3 = list[k];
                        if (unit3.Side == EUnitSide.Enemy)
                        {
                            stringBuilder.Append("{");
                            this.SetValue(ref stringBuilder, "\"eid\":\"", (long)k, "\",");
                            this.SetValue(ref stringBuilder, "\"iname\":\"", unit3.UnitParam.iname, "\",");
                            this.SetValue(ref stringBuilder, "\"hp\":", (!unit3.IsDead) ? ((long)unit3.CurrentStatus.param.hp) : 0L);
                            this.SetValue(ref stringBuilder, "\"jewel\":", (long)unit3.CurrentStatus.param.mp, string.Empty);
                            stringBuilder.Append("},");
                        }
                    }
                }
                stringBuilder.Length--;
                stringBuilder.Append("]");
            }
            SupportData supportData = GlobalVars.SelectedSupport.Get();

            if (GlobalVars.SelectedFriendID != null && supportData != null)
            {
                stringBuilder.Append(",\"help\":{\"fuid\":\"");
                stringBuilder.Append(GlobalVars.SelectedFriendID);
                stringBuilder.Append("\",\"cost\":");
                stringBuilder.Append(supportData.Cost);
                stringBuilder.Append("}");
            }
            if (!string.IsNullOrEmpty(trophyprog))
            {
                stringBuilder.Append(",");
                stringBuilder.Append(trophyprog);
            }
            if (!string.IsNullOrEmpty(bingoprog))
            {
                stringBuilder.Append(",");
                stringBuilder.Append(bingoprog);
            }
            if (!string.IsNullOrEmpty(maxdata))
            {
                stringBuilder.Append(",");
                stringBuilder.Append(maxdata);
            }
            stringBuilder.Append("}");
            this.body = WebAPI.GetRequestString(stringBuilder.ToString());
        }