コード例 #1
0
    public void SelectCP(PhxCommandpost cp)
    {
        int idx = Array.IndexOf(CommandPosts, cp);

        if (idx >= 0)
        {
            SelectCP(idx);
        }
    }
コード例 #2
0
    void Start()
    {
        RawImage image = GetComponent <RawImage>();

        Debug.Assert(image != null);

        MapMat = image.materialForRendering;
        Debug.Assert(MapMat != null);

        CPSelectSound = SoundLoader.LoadSound("ui_menumove");

        // TODO: Load texture from "MapTexture" property specified in PhxCommandpost class
        Texture2D cpTexture = TextureLoader.Instance.ImportUITexture("hud_flag_icon");

        MapMat.SetTexture("_CPTex", cpTexture);

        if (SCENE.MapTexture != null)
        {
            Debug.Assert(SCENE.MapTexture.width == SCENE.MapTexture.height);
            MapMat.SetTexture("_MapTex", SCENE.MapTexture);
        }

        RectTransform rt = transform as RectTransform;

        MapMat.SetVector("_SpriteSize", new Vector4(rt.sizeDelta.x, rt.sizeDelta.y));

        if (Mode == PhxUIMapMode.StaticClickable)
        {
            for (int i = 0; i < CPButtons.Length; ++i)
            {
                CPButtons[i] = Instantiate(CPButtonPrefab, transform);
                CPButtons[i].gameObject.SetActive(false);

                RectTransform t = CPButtons[i].transform as RectTransform;
                t.sizeDelta = new Vector2(cpTexture.width, cpTexture.height);

                int    idx = i;
                Button btn = CPButtons[i].GetComponent <Button>();
                btn.onClick.AddListener(() =>
                {
                    PhxCommandpost cp = CommandPosts[idx];
                    if (cp.Team == MATCH.Player.Team)
                    {
                        SelectCP(idx);
                    }
                });
            }
        }
    }
コード例 #3
0
    public static int GetCommandPostTeam(int?cpPtr)
    {
        if (!cpPtr.HasValue)
        {
            return(0);
        }
        PhxCommandpost cp = RTS.GetInstance <PhxCommandpost>(cpPtr.Value);

        if (cp != null)
        {
            return(cp.Team);
        }
        Debug.LogWarning($"Illegal CommandPost Lua pointer '{cpPtr.Value}'!");
        return(0);
    }
コード例 #4
0
 // For un-assignment, use IPhxControlableInstance.UnAssign()!
 public void RemovePawn()
 {
     Pawn        = null;
     CapturePost = null;
 }
コード例 #5
0
 void OnCPSelected(PhxCommandpost cp)
 {
     //Debug.Log($"Selected CP '{cp.name}'");
     SpawnCP = cp;
 }
コード例 #6
0
ファイル: PhxHUD.cs プロジェクト: Ben1138/SWBF2Phoenix
    // Update is called once per frame
    void Update()
    {
        ReinforcementTeam1.text = Match.GetReinforcementCount(1).ToString();
        ReinforcementTeam2.text = Match.GetReinforcementCount(2).ToString();

        if (Match.Player.Pawn != null)
        {
            Vector3 playerPos = Match.Player.Pawn.GetInstance().transform.position;
            Map.MapOffset.x = -playerPos.x;
            Map.MapOffset.y = -playerPos.z;

            IPhxWeapon weapPrim = Match.Player.Pawn.GetPrimaryWeapon();
            if (weapPrim != null)
            {
                int ammo     = weapPrim.GetMagazineAmmo();
                int magazine = weapPrim.GetMagazineSize();

                float reloadProgress = weapPrim.GetReloadProgress();
                if (reloadProgress < 1f)
                {
                    int reload = Mathf.Min(magazine - ammo, weapPrim.GetAvailableAmmo());
                    ammo += (int)(reload * reloadProgress);
                }

                CrosshairMat.SetFloat("_Ammo", ammo);
                CrosshairMat.SetFloat("_Magazin", magazine);

                AmmoPrim.text = weapPrim.GetTotalAmmo().ToString();
            }
            else
            {
                CrosshairMat.SetFloat("_Ammo", 0);
                AmmoPrim.text = "-";
            }

            PhxInstance aim = Match.Player.Pawn.GetAim();
            if (aim != null)
            {
                if (aim.Team != 0)
                {
                    AimFixation = Mathf.Clamp01(AimFixation + Time.deltaTime / AimSpeed);
                }
                else
                {
                    AimFixation = Mathf.Clamp01(AimFixation - Time.deltaTime / AimSpeed);
                }
                CrosshairMat.SetColor("_Color", Match.GetTeamColor(aim.Team));
            }
            else
            {
                AimFixation = Mathf.Clamp01(AimFixation - Time.deltaTime / AimSpeed);
                CrosshairMat.SetColor("_Color", Color.white);
            }

            CrosshairMat.SetFloat("_Fixation", AimFixation);
        }

        PhxCommandpost cp             = Match.Player.CapturePost;
        bool           displayCapture = cp != null && ((cp.Team != Match.Player.Team) || !Match.IsFriend(cp.CaptureTeam, Match.Player.Team));

        CaptureDisplay.gameObject.SetActive(displayCapture);
        if (displayCapture)
        {
            Color color    = Match.GetTeamColor(cp.CaptureTeam);
            float progress = cp.GetCaptureProgress();
            if (cp.CaptureToNeutral)
            {
                color    = Match.GetTeamColor(cp.Team);
                progress = 1f - progress;
            }

            // remap for more consistent HUD icon fill
            progress = Mathf.Lerp(0.1f, 0.95f, progress);

            CaptureMat.SetFloat("_CaptureProgress", progress);
            CaptureMat.SetColor("_CaptureColor", color);
            CaptureMat.SetFloat("_CaptureDispute", cp.CaptureDisputed ? 1f : 0f);
        }

        TimerDisplay.gameObject.SetActive(Match.ShowTimer.HasValue);
        if (Match.ShowTimer.HasValue)
        {
            TimerDB.GetTimer(Match.ShowTimer.Value, out var timer);

            TimeSpan t = TimeSpan.FromSeconds(timer.Time);
            TimerDisplay.text  = string.Format("{0:D2}:{1:D2}", t.Minutes, t.Seconds);
            TimerDisplay.color = PhxRuntimeMatch.ColorNeutral;
        }

        (int?timerIdx, PhxRuntimeMatch.PhxTeam.TimerDisplay display) = Match.GetTeamTimer(Match.Player.Team);
        VicDefTimerDisplay.gameObject.SetActive(timerIdx.HasValue);
        if (timerIdx.HasValue)
        {
            Color color = PhxRuntimeMatch.ColorNeutral;
            if (display == PhxRuntimeMatch.PhxTeam.TimerDisplay.Defeat)
            {
                color = PhxRuntimeMatch.ColorEnemy;
            }
            else if (display == PhxRuntimeMatch.PhxTeam.TimerDisplay.Victory)
            {
                color = PhxRuntimeMatch.ColorFriendly;
            }

            TimerDB.GetTimer(timerIdx.Value, out var timer);

            TimeSpan t = TimeSpan.FromSeconds(timer.Time);
            VicDefTimerDisplay.text  = string.Format("{0:D2}:{1:D2}", t.Minutes, t.Seconds);
            VicDefTimerDisplay.color = color;
        }
    }