Exemplo n.º 1
0
    void LateUpdate()
    {
        float deltaTime = Time.deltaTime;

        if (Mode == CamMode.Free)
        {
            transform.position += transform.forward * Input.GetAxis("Vertical") * deltaTime * FreeMoveSpeed;
            transform.position += transform.right * Input.GetAxis("Horizontal") * deltaTime * FreeMoveSpeed;
            transform.position += transform.up * Input.GetAxis("UpDown") * deltaTime * FreeMoveSpeed;

            if (Input.GetMouseButton(1))
            {
                float newRotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * FreeRotationSpeed;
                float newRotationY = transform.localEulerAngles.x - Input.GetAxis("Mouse Y") * FreeRotationSpeed;
                transform.localEulerAngles = new Vector3(newRotationY, newRotationX, 0f);
            }
        }
        else if (Mode == CamMode.Follow)
        {
            Vector3 rotPoint = FollowInstance.GetInstance().transform.position;
            rotPoint.y += PositionOffset.y;


            //Vector3 viewDir = (FollowInstance.GetTargetPosition() - rotPoint).normalized;
            Vector3    viewDir      = PhxGameRuntime.GetMatch().Player.ViewDirection;
            Vector3    camTargetPos = rotPoint + viewDir * PositionOffset.z;
            Quaternion camTargetRot = Quaternion.LookRotation(viewDir);
            camTargetPos += camTargetRot * new Vector3(PositionOffset.x, 0f, 0f);

            transform.position = camTargetPos; // Vector3.Lerp(transform.position, camTargetPos, deltaTime * FollowSpeed);
            transform.rotation = camTargetRot; // Quaternion.Slerp(transform.rotation, camTargetRot, deltaTime * FollowSpeed);
        }
    }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        PhxRuntimeEnvironment rt = PhxGameRuntime.GetEnvironment();

        if (rt != null)
        {
            Percentage = Mathf.Lerp(Percentage, rt.GetLoadingProgress(), Time.deltaTime * PercentageSpeed);
            LoadIcon.material.SetFloat("_Percent", Percentage);
        }

        if (ImageSet)
        {
            if (FadeImagePlayback < FadeImageDuration)
            {
                FadeImagePlayback += Time.deltaTime;
            }

            LoadImage.color = Color.Lerp(Color.black, Color.white, FadeImagePlayback / FadeImageDuration);
        }

        if (State == LSState.FadeIn && FadeScreenPlayback < FadeScreenDuration)
        {
            FadeScreenPlayback += Time.deltaTime;
        }
        else if (State == LSState.FadeOut && FadeScreenPlayback > 0.0)
        {
            FadeScreenPlayback -= Time.deltaTime;
        }

        CVGroup.alpha = FadeScreenPlayback / FadeScreenDuration;
    }
Exemplo n.º 3
0
    void OnGUI()
    {
        PhxLuaRuntime rt = PhxGameRuntime.GetLuaRuntime();

        if (!Application.isPlaying || rt == null)
        {
            EditorGUILayout.LabelField("LUA is not running");
            return;
        }

        ScrollPos = EditorGUILayout.BeginScrollView(ScrollPos);
        PhxTimerDB tdb = PhxGameRuntime.GetTimerDB();

        for (int i = 0; i < tdb.InUseIndices.Count; ++i)
        {
            int idx = tdb.InUseIndices[i];
            tdb.GetTimer(idx, out PhxTimerDB.PhxTimer timer);

            EditorGUILayout.LabelField("Name", timer.Name);
            EditorGUILayout.LabelField("Time", (Mathf.Round(timer.Time * 100f) / 100f).ToString());
            EditorGUILayout.LabelField("Rate", timer.Rate.ToString());
            EditorGUILayout.LabelField("IsRunning", timer.IsRunning.ToString());
            GUILayout.Space(20);
        }
        EditorGUILayout.EndScrollView();
    }
Exemplo n.º 4
0
    void OnGUI()
    {
        PhxRuntimeEnvironment env = PhxGameRuntime.GetEnvironment();

        if (!Application.isPlaying || PhxGameRuntime.Instance == null || env == null)
        {
            EditorGUILayout.LabelField("Game is not running");
            return;
        }

        PhxPath gamePath = PhxGameRuntime.GamePath;

        EditorGUILayout.LabelField("Environment Path", env.Path - gamePath);
        EditorGUILayout.LabelField("Fallback Path", env.FallbackPath - gamePath);
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Environment Stage", env.Stage.ToString());
        EditorGUILayout.Space();

        foreach (var lvl in env.LVLs)
        {
            EditorGUILayout.LabelField(lvl.RelativePath, "Loaded", lvl.bIsFallback ? FallbackLVLStyle : EnvLVLStyle);
        }
        foreach (var lvl in env.LoadingLVLs)
        {
            EditorGUILayout.LabelField(lvl.PathPartial, string.Format("{0:0.} %", env.GetProgress(lvl.Handle) * 100.0f), lvl.bIsFallback ? FallbackLVLStyle : EnvLVLStyle);
        }
    }
Exemplo n.º 5
0
    void OnGUI()
    {
        PhxLuaRuntime rt = PhxGameRuntime.GetLuaRuntime();

        if (!Application.isPlaying || rt == null)
        {
            EditorGUILayout.LabelField("LUA is not running");
            return;
        }

        PhxRuntimeMatch gm = PhxGameRuntime.GetMatch();

        ScrollPos = EditorGUILayout.BeginScrollView(ScrollPos);
        for (int i = 0; i < PhxRuntimeMatch.MAX_TEAMS; ++i)
        {
            PhxRuntimeMatch.PhxTeam t = gm.Teams[i];

            EditorGUILayout.LabelField("Team ID", (i + 1).ToString());
            EditorGUILayout.LabelField("Name", t.Name);
            EditorGUILayout.LabelField("Aggressiveness", t.Aggressiveness.ToString());
            EditorGUILayout.LabelField("Icon", t.Icon?.ToString());
            EditorGUILayout.LabelField("Unit Count", t.UnitCount.ToString());
            EditorGUILayout.LabelField("Reinforcement Count", t.ReinforcementCount.ToString());
            EditorGUILayout.LabelField("Spawn Delay", t.SpawnDelay.ToString());
            EditorGUILayout.LabelField("Hero Class", t.HeroClass?.Name);
            GUILayout.Label("Unit Classes:");
            foreach (PhxRuntimeMatch.PhxUnitClass unitClass in t.UnitClasses)
            {
                EditorGUILayout.LabelField("    " + unitClass.Unit.Name, unitClass.Count.ToString());
            }
            GUILayout.Space(20);
        }
        EditorGUILayout.EndScrollView();
    }
Exemplo n.º 6
0
    void Loaded()
    {
        Debug.Log("Loaded.");

        string[] classNames =
        {
            "rep_inf_ep2_rifleman",
            "rep_inf_ep2_rocketeer",
            "rep_inf_ep2_sniper",
            "rep_inf_ep2_engineer",
            "rep_inf_ep2_jettrooper",
            "rep_inf_ep3_rifleman",
            "rep_inf_ep3_rocketeer",
            "rep_inf_ep3_sniper",
            "rep_inf_ep3_sniper_felucia",
            "rep_inf_ep3_engineer",
            "rep_inf_ep3_officer",
            "rep_inf_ep3_jettrooper",
        };

        PhxRuntimeScene scene = PhxGameRuntime.GetScene();

        PhxClass[] classes = new PhxClass[classNames.Length];

        for (int i = 0; i < classes.Length; ++i)
        {
            classes[i] = scene.GetClass(classNames[i]);
            if (classes[i] == null)
            {
                Debug.LogError($"Cannot find class '{classNames[i]}'!");
                return;
            }
        }

        if (SpawnMobs)
        {
            Instances = new PhxSoldier[Width * Height];
            for (int x = 0; x < Width; ++x)
            {
                for (int y = 0; y < Height; ++y)
                {
                    Vector3 pos = new Vector3(x * -Padding, 0f, y * -Padding);
                    pos.x += Random.Range(-0.2f, 0.2f);
                    pos.z += Random.Range(-0.2f, 0.2f);

                    PhxClass spawnClass = classes[Random.Range(0, classes.Length)];

                    int idx = x + (Width * y);
                    Instances[idx] = MATCH.SpawnAI <PhxAnimTestController>(spawnClass, pos, Quaternion.identity);
                    Instances[idx].Fixate();
                }
            }
        }

        if (SpawnPlayer)
        {
            MATCH.SpawnPlayer(classes[5], transform.position, Quaternion.identity);
        }
    }
Exemplo n.º 7
0
        public void Invoke(params object[] args)
        {
            PhxLuaRuntime rt = PhxGameRuntime.GetLuaRuntime();

            if (rt != null)
            {
                rt.CallLuaFunction(RefIdx, 0, false, false, args);
            }
        }
Exemplo n.º 8
0
    protected override TreeViewItem BuildRoot()
    {
        var root = new TreeViewItem {
            id = 0, depth = -1, displayName = "TABLE"
        };

        PhxLuaRuntime runtime = PhxGameRuntime.GetLuaRuntime();

        if (!Application.isPlaying || runtime == null)
        {
            return(root);
        }
        Lua L = runtime.GetLua();

        // BuildRoot is called every time Reload is called to ensure that TreeViewItems
        // are created from data. Here we create a fixed set of items. In a real world example,
        // a data model should be passed into the TreeView and the items created from the model.

        // This section illustrates that IDs should be unique. The root item is required to
        // have a depth of -1, and the rest of the items increment from that.

        PhxLuaRuntime.Table table = runtime.ToValue(TableIdx) as PhxLuaRuntime.Table;
        if (table != null)
        {
            var allItems = new List <TreeViewItem>();
            int id       = 0;

            void AddTable(PhxLuaRuntime.Table t, int depth)
            {
                foreach (KeyValuePair <object, object> entry in table)
                {
                    if (entry.Value is PhxLuaRuntime.Table)
                    {
                        AddTable((PhxLuaRuntime.Table)entry.Value, depth + 1);
                    }
                    else
                    {
                        allItems.Add(new TreeViewItem
                        {
                            id          = id++,
                            depth       = depth,
                            displayName = string.Format($"{entry.Key.ToString()} = {entry.Value.ToString()}")
                        });
                    }
                }
            }

            AddTable(table, 0);

            // Utility method that initializes the TreeViewItem.children and .parent for all items.
            SetupParentsAndChildrenFromDepths(root, allItems);
        }


        // Return root of the tree
        return(root);
    }
Exemplo n.º 9
0
 void UpdateColor()
 {
     HoloColor = PhxGameRuntime.GetMatch().GetTeamColor(Team);
     HoloRay?.material.SetColor("_EmissiveColor", HoloColor);
     if (Light != null)
     {
         Light.color = HoloColor;
     }
 }
Exemplo n.º 10
0
    void OnGUI()
    {
        PhxLuaRuntime runtime = PhxGameRuntime.GetLuaRuntime();

        if (!Application.isPlaying || runtime == null)
        {
            EditorGUILayout.LabelField("LUA is not running");
            return;
        }
        Lua L = runtime.GetLua();

        GUILayout.BeginHorizontal();
        LuaCode = GUILayout.TextArea(LuaCode, /*EditorStyle, */ GUILayout.Width(400), GUILayout.ExpandHeight(true));

        GUILayout.BeginVertical(GUILayout.ExpandWidth(true));
        int stackSize = L.GetTop();

        for (int i = stackSize - 1; i >= 0; --i)
        {
            Lua.ValueType type    = L.Type(i);
            string        typeStr = type.ToString();
            if (type == Lua.ValueType.TABLE)
            {
                GUILayout.BeginHorizontal();
                EditorGUILayout.PrefixLabel("TABLE");
                if (GUILayout.Button(TreeView == null ? "Expand" : "Collapse"))
                {
                    if (TreeView == null)
                    {
                        TreeView = new TableTreeView(new TreeViewState(), i);
                    }
                    else
                    {
                        TreeView = null;
                    }
                }
                Rect last = GUILayoutUtility.GetLastRect();
                GUILayout.EndHorizontal();
                if (TreeView != null && TreeView.TableIdx == i)
                {
                    GUILayout.Space(100);
                    TreeView.OnGUI(new Rect(last.x, last.y + last.height, position.width, 100));
                }
            }
            else
            {
                object value    = runtime.ToValue(i);
                string valueStr = value != null?value.ToString() : "NIL";

                EditorGUILayout.LabelField(typeStr, valueStr);
            }
        }

        GUILayout.Space(20);
        EditorGUILayout.LabelField("GC Count", L.GetGCCount().ToString());
        EditorGUILayout.LabelField("GC Threshold", L.GetGCThreshold().ToString());
        EditorGUILayout.LabelField("Used callbacks", L.UsedCallbackCount.ToString() + "/200");
        GUILayout.EndVertical();
        GUILayout.EndHorizontal();

        if (GUILayout.Button("Execute"))
        {
            runtime.ExecuteString(LuaCode);
        }
    }
Exemplo n.º 11
0
    public static void SetClassProperty(string className, string propName, object propValue)
    {
        PhxRuntimeScene scene = PhxGameRuntime.GetScene();

        scene?.SetClassProperty(className, propName, propValue);
    }