Exemplo n.º 1
0
        public static V_Object CreateSkeleton(Vector3 position, Material material)
        {
            V_Object   instancedObject       = V_Object.CreateObject();
            GameObject gameObject            = new GameObject("Skeleton", typeof(MeshFilter), typeof(MeshRenderer));
            Transform  instantiatedTransform = gameObject.transform;

            instantiatedTransform.position = position;
            //Transform instantiatedTransform = UnityEngine.Object.Instantiate(SpriteHolder.instance.t_pfV_Skeleton, position, Quaternion.identity);
            V_IObjectTransform transform = new V_ObjectTransform(instantiatedTransform);

            instancedObject.AddRelatedObject(transform);
            V_IObjectTransformBody transformBody = new V_ObjectTransformBody(instantiatedTransform, material);

            instancedObject.AddRelatedObject(transformBody);
            instancedObject.AddRelatedObject(new V_IHasWorldPosition_Class(transform.GetPosition));

            V_UnitSkeleton unitSkeleton = new V_UnitSkeleton(1f, transformBody.ConvertBodyLocalPositionToWorldPosition, transformBody.SetBodyMesh);

            instancedObject.AddRelatedObject(unitSkeleton);
            instancedObject.AddActiveLogic(new V_ObjectLogic_SkeletonUpdater(unitSkeleton));
            V_UnitAnimation unitAnimation = new V_UnitAnimation(unitSkeleton);

            instancedObject.AddRelatedObject(unitAnimation);

            return(instancedObject);
        }
Exemplo n.º 2
0
        public static V_Object CreateObject(string name, V_Main.UpdateType updateType = V_Main.UpdateType.Main)
        {
            V_Object vObject = CreateObject(updateType);

            vObject.name = name;
            return(vObject);
        }
Exemplo n.º 3
0
        public static V_Object CreateSkeletonPresetAnim_DebugDash(Vector3 position, Color color, float frameRate = 1f)
        {
            Material material = new Material(GetWhitePixelMaterial());

            material.color = color;
            V_Object vObject = V_Object.CreateSkeletonPresetAnim(position, material, UnitAnim.GetUnitAnim("EffectDash"), frameRate, new Vector3(0, 1, 0), new Vector3(3f, 1f, 1f), 100);

            return(vObject);
        }
Exemplo n.º 4
0
        public static void TryDestroyObject(string name)
        {
            V_Object vObject = GetObject(name);

            if (vObject != null)
            {
                vObject.DestroySelf();
            }
        }
Exemplo n.º 5
0
        public static V_Object CreateSkeletonPresetAnim(Vector3 position, Material material, UnitAnimType unitAnimType, Vector3 dir, float frameRateMod)
        {
            V_Object instancedObject = CreateSkeleton(position, material);

            V_UnitSkeleton.OnAnimComplete onAnimComplete = delegate(UnitAnim unitAnim) {
                instancedObject.DestroySelf();
            };
            instancedObject.GetLogic <V_UnitAnimation>().PlayAnimForced(unitAnimType, dir, frameRateMod, onAnimComplete, null, null);
            return(instancedObject);
        }
Exemplo n.º 6
0
        public static V_Object CreateObjectGameObject(GameObject gameObject)
        {
            V_Object           instancedObject    = V_Object.CreateObject();
            Transform          instancedTransform = gameObject.transform;
            V_IObjectTransform instanceTransform  = new V_ObjectTransform(instancedTransform);

            instancedObject.AddRelatedObject(instanceTransform);
            instancedObject.AddRelatedObject(new V_IHasWorldPosition_Class(instanceTransform.GetPosition));
            return(instancedObject);
        }
Exemplo n.º 7
0
        public static V_Object CreateObjectPrefab(GameObject prefab, Vector3 position)
        {
            V_Object           instancedObject    = V_Object.CreateObject();
            Transform          instancedTransform = UnityEngine.Object.Instantiate(prefab, position, Quaternion.identity).transform;
            V_IObjectTransform instanceTransform  = new V_ObjectTransform(instancedTransform);

            instancedObject.AddRelatedObject(instanceTransform);
            instancedObject.AddRelatedObject(new V_IHasWorldPosition_Class(instanceTransform.GetPosition));
            return(instancedObject);
        }
Exemplo n.º 8
0
        public static V_Object CreateSkeletonPresetAnim(Vector3 position, Material material, UnitAnimType unitAnimType, Vector3 dir, float frameRateMod, Vector3 rotatePrefabDir, Vector3 scalePrefab)
        {
            V_Object instancedObject = CreateSkeleton(position, material);

            V_UnitSkeleton.OnAnimComplete onAnimComplete = delegate(UnitAnim unitAnim) {
                instancedObject.DestroySelf();
            };
            instancedObject.GetLogic <V_UnitAnimation>().PlayAnimForced(unitAnimType, dir, frameRateMod, onAnimComplete, null, null);
            instancedObject.GetLogic <V_IObjectTransform>().SetEulerZ(GetAngleFromVector(rotatePrefabDir));
            instancedObject.GetLogic <V_IObjectTransform>().SetScale(scalePrefab);
            return(instancedObject);
        }
        private static void ApplyEffect(Effect effect)
        {
            float timeScale = 1f;

            switch (effect)
            {
            case Effect.Tutorial_WaitingForFirstAttack:
            case Effect.Tutorial_WaitingForComboWindow:
            case Effect.TutorialVillage_WaitingForSetupWaypoint:
            case Effect.Hero_Intro:
            case Effect.Window_GameMenu:
            case Effect.Window_Map:
            case Effect.SecondChance:
                timeScale = 0f;
                break;

            case Effect.Combo_SuperSelf:
                timeScale = .3f;
                break;

            case Effect.SecondChance_AfterEffect:
                timeScale = .1f;
                break;

            case Effect.SecondChance_AfterEffect_2:
                timeScale = .3f;
                break;

            case Effect.SecondChance_AfterEffect_3:
                timeScale = .6f;
                break;

            case Effect.Combo_Slowdown:
                timeScale = .1f;
                break;

            case Effect.Player_Dead:
                timeScale = 5f;
                break;
            }
            if (timeScale == 0f)
            {
                //GameHandler.FootstepsSoundPause();
            }
            else
            {
                //GameHandler.FootstepsSoundResume();
            }
            V_TimeScaleManager.timeScale = timeScale;

            V_Object.SetAllDeltaTimeModifier(timeScale);
        }
Exemplo n.º 10
0
        public static V_Object CreateSkeletonPresetAnim(Vector3 position, Material material, UnitAnim unitAnim, float frameRateMod, Vector3 rotatePrefabDir, Vector3 scalePrefab, int sortingOrderOffset)
        {
            V_Object instancedObject = CreateSkeleton(position, material);

            V_UnitSkeleton.OnAnimComplete onAnimComplete = delegate(UnitAnim u) {
                instancedObject.DestroySelf();
            };
            instancedObject.GetLogic <V_IObjectTransform>().GetTransform().GetComponent <CodeMonkey.MonoBehaviours.PositionRendererSorter>().SetOffset(sortingOrderOffset);
            instancedObject.GetLogic <V_UnitAnimation>().PlayAnimForced(unitAnim, frameRateMod, onAnimComplete, null, null);
            instancedObject.GetLogic <V_IObjectTransform>().SetEulerZ(GetAngleFromVector(rotatePrefabDir));
            instancedObject.GetLogic <V_IObjectTransform>().SetScale(scalePrefab);
            return(instancedObject);
        }
Exemplo n.º 11
0
        public static List <V_Object> FilterObjectsWithTheseLogicTypes <T>(List <V_Object> objectList)
        {
            List <V_Object> ret = new List <V_Object>();

            for (int i = 0; i < objectList.Count; i++)
            {
                V_Object objectInstance = objectList[i];
                T        logic          = objectInstance.GetLogic <T>();
                if (logic != null)
                {
                    // Contains logic
                    ret.Add(objectInstance);
                }
            }
            return(ret);
        }
 private static void UpdateTimeScale()
 {
     // Get highest priority effect
     if (activeEffectsList.Count <= 0)
     {
         // No effects
         //Debug.Log("TimeScale Effect: "+"None"+", "+"1");
         //GameHandler.FootstepsSoundResume();
         timeScale = 1f;
         V_Object.SetAllDeltaTimeModifier(timeScale);
     }
     else
     {
         // Sort by priority
         for (int i = 0; i < activeEffectsList.Count; i++)
         {
             for (int j = i + 1; j < activeEffectsList.Count; j++)
             {
                 if (GetEffectPriority(activeEffectsList[j]) > GetEffectPriority(activeEffectsList[i]))
                 {
                     Effect tmp = activeEffectsList[i];
                     activeEffectsList[i] = activeEffectsList[j];
                     activeEffectsList[j] = tmp;
                 }
             }
         }
         ApplyEffect(activeEffectsList[0]);
     }
     // Update individual time
     foreach (TimeType en in System.Enum.GetValues(typeof(TimeType)))
     {
         deltaTimeModifierDic[en] = 1f;
     }
     if (HasEffect(Effect.Hero_Intro) || HasEffect(Effect.Window_GameMenu) || HasEffect(Effect.Window_Map))
     {
         deltaTimeModifierDic[TimeType.Combo_SuperSelfTimer] = 0f;
         deltaTimeModifierDic[TimeType.Combo_RefreshTimer]   = 0f;
     }
     if (HasEffect(Effect.Window_GameMenu) || HasEffect(Effect.Window_Map))
     {
         deltaTimeModifierDic[TimeType.Hero_Intro] = 0f;
     }
 }
Exemplo n.º 13
0
        public static V_Object GetClosestFromList(Vector3 position, List <V_Object> objectList)
        {
            V_Object closest = null;

            for (int i = 0; i < objectList.Count; i++)
            {
                if (closest == null)
                {
                    closest = objectList[i];
                }
                else
                {
                    // No closest
                    if (Vector3.Distance(position, objectList[i].GetPosition()) < Vector3.Distance(position, closest.GetPosition()))
                    {
                        closest = objectList[i];
                    }
                }
            }
            return(closest);
        }
Exemplo n.º 14
0
        private static void Update(float deltaTime)
        {
            foreach (UpdateType updateType in updateTypeArr)
            {
                List <DelUpdate> tmpOnUpdateList = new List <DelUpdate>(onUpdateListTypeDic[updateType]);
                for (int i = 0; i < tmpOnUpdateList.Count; i++)
                {
                    tmpOnUpdateList[i](deltaTime * updateTimeModDic[updateType]);
                }
            }

            // Update V_Object's
            V_Object.Static_Update(deltaTime, updateTimeModDic);

            foreach (UpdateType updateType in updateTypeArr)
            {
                List <DelUpdate> tmpOnLateUpdateList = new List <DelUpdate>(onLateUpdateListTypeDic[updateType]);
                for (int i = 0; i < tmpOnLateUpdateList.Count; i++)
                {
                    tmpOnLateUpdateList[i](deltaTime * updateTimeModDic[updateType]);
                }
            }
        }
Exemplo n.º 15
0
        public static V_Object CreateSkeletonPresetAnim_DebugDash(Vector3 position)
        {
            V_Object vObject = V_Object.CreateSkeletonPresetAnim(position, GetWhitePixelMaterial(), UnitAnim.GetUnitAnim("EffectDash"), 1f, new Vector3(0, 1, 0), new Vector3(3f, 1f, 1f), 100);

            return(vObject);
        }
Exemplo n.º 16
0
        public static V_Object CreateSkeletonPresetAnim_DebugDash(Vector3 position, Vector3 rotationDir, Vector3 localScale)
        {
            V_Object vObject = V_Object.CreateSkeletonPresetAnim(position, GetWhitePixelMaterial(), UnitAnim.GetUnitAnim("EffectDash"), 1f, rotationDir, localScale, 100);

            return(vObject);
        }