Пример #1
0
    public static PhxRuntimeEnvironment Create(PhxPath envPath, PhxPath fallbackPath = null, bool initMatch = true)
    {
        if (!envPath.Exists())
        {
            Debug.LogErrorFormat("Given environment path '{0}' doesn't exist!", envPath);
            return(null);
        }

        if (fallbackPath == null)
        {
            fallbackPath = envPath;
        }
        Debug.Assert(fallbackPath.Exists());

        PhxAnimationLoader.ClearDB();
        GameLuaEvents.Clear();

        PhxRuntimeEnvironment rt = new PhxRuntimeEnvironment(envPath, fallbackPath);

        rt.ScheduleLVLRel("core.lvl");
        rt.ScheduleLVLRel("shell.lvl");
        rt.ScheduleLVLRel("common.lvl");
        rt.ScheduleLVLRel("mission.lvl");
        rt.ScheduleSoundBankRel("sound/common.bnk");

        rt.RTScene = new PhxRuntimeScene(rt, rt.EnvCon);
        rt.Match   = initMatch ? new PhxRuntimeMatch() : null;
        rt.Timers  = new PhxTimerDB();

        PhxAnimationLoader.Con = rt.EnvCon;

        return(rt);
    }
Пример #2
0
    void ApplyTeam(int oldTeam)
    {
        if (Team == oldTeam)
        {
            // nothing to do
            return;
        }

        CaptureTimer = 0.0f;

        AudioCapture.clip = Team == 0 ? C.ChargeSound.Get <AudioClip>(0) : C.DischargeSound.Get <AudioClip>(0);
        AudioCapture.Play();

        AudioAmbient.loop = true;
        AudioAction.clip  = Team == 0 ? C.LostSound.Get <AudioClip>(0) : C.CapturedSound.Get <AudioClip>(0);
        AudioAction.Play();

        HoloPresence     = 0.0f;
        HoloPresenceDest = 1.0f;

        if (Team == 0)
        {
            GameLuaEvents.Invoke(GameLuaEvents.Event.OnFinishNeutralize, Scene.GetInstanceIndex(this));
        }
        else
        {
            GameLuaEvents.Invoke(GameLuaEvents.Event.OnFinishCapture, Scene.GetInstanceIndex(this));
            GameLuaEvents.Invoke(GameLuaEvents.Event.OnFinishCaptureName, name, Scene.GetInstanceIndex(this));
        }

        RefreshCapture();
        UpdateColor();
    }
Пример #3
0
    public void Tick(float deltaTime)
    {
        for (int i = 0; i < InUseIndices.Count; ++i)
        {
            int idx = InUseIndices[i];
            if (Timers[idx].IsRunning)
            {
                Timers[idx].Time -= Timers[idx].Rate * deltaTime;
                if (Timers[idx].Time <= 0f)
                {
                    GameLuaEvents.InvokeParameterized(GameLuaEvents.Event.OnTimerElapse, idx);

                    Timers[idx].Time      = 0f;
                    Timers[idx].IsRunning = false;
                }
            }
        }
    }
Пример #4
0
 public static void OnFinishNeutralize(PhxLuaRuntime.LFunction callback)
 {
     GameLuaEvents.Register(GameLuaEvents.Event.OnFinishNeutralize, callback);
     // callback paramters:
     // - postPtr
 }
Пример #5
0
 public static void OnFinishCaptureName(PhxLuaRuntime.LFunction callback, string cpName)
 {
     GameLuaEvents.Register(GameLuaEvents.Event.OnFinishCaptureName, callback, cpName);
     // callback paramters:
     // - postPtr
 }
Пример #6
0
 public static void OnLeaveRegion(PhxLuaRuntime.LFunction callback, string regionName)
 {
     GameLuaEvents.Register(GameLuaEvents.Event.OnLeaveRegion, callback, regionName);
 }
Пример #7
0
 public static void OnEnterRegionTeam(PhxLuaRuntime.LFunction callback, string regionName, int teamIdx)
 {
     GameLuaEvents.Register(GameLuaEvents.Event.OnEnterRegionTeam, callback, (regionName, teamIdx));
 }
Пример #8
0
 public static void OnTimerElapse(PhxLuaRuntime.LFunction callback, int timer)
 {
     GameLuaEvents.Register(GameLuaEvents.Event.OnTimerElapse, callback, timer);
 }