//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Thursday, September 14, 2017
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
using vnxbqy.UI;
|
|
public class ExperienceGetBehaviour
|
{
|
public static void Init()
|
{
|
PlayerMainDate.Event_Experience += OnGetNewExperience;
|
}
|
|
public static void UnInit()
|
{
|
PlayerMainDate.Event_Experience -= OnGetNewExperience;
|
}
|
|
static void OnGetNewExperience(int _source, int _billionsExperience, int _unitExperience)
|
{
|
if (!WindowCenter.Instance.IsOpen("ExperienceGetWin"))
|
{
|
WindowCenter.Instance.Open<ExperienceGetWin>(true);
|
}
|
|
var experience = _billionsExperience * (long)100000000 + _unitExperience;
|
if (experienceQueue.Count >= queueMax)
|
{
|
experienceQueue.Dequeue();
|
}
|
|
experienceQueue.Enqueue(new Experience()
|
{
|
source = _source,
|
value = experience
|
});
|
}
|
|
public static bool GetExperience(out Experience exp)
|
{
|
if (experienceQueue.Count > 0)
|
{
|
exp = experienceQueue.Dequeue();
|
return true;
|
}
|
else
|
{
|
exp = default(Experience);
|
return false;
|
}
|
}
|
|
public static void Clear()
|
{
|
experienceQueue.Clear();
|
}
|
|
static int queueMax = 10;
|
static Queue<Experience> experienceQueue = new Queue<Experience>();
|
|
public struct Experience
|
{
|
public int source;
|
public long value;
|
}
|
|
}
|
|
namespace vnxbqy.UI
|
{
|
public class ExperienceGetWin : Window
|
{
|
|
[SerializeField]
|
Transform m_ResetPoint;
|
|
float interval = 0.2f;
|
float nextShowTime = 0f;
|
|
#region Built-in
|
protected override void BindController()
|
{
|
}
|
|
protected override void AddListeners()
|
{
|
}
|
|
protected override void OnPreOpen()
|
{
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
ExperienceGetBehaviour.Clear();
|
ExperienceFloatPool.RecycleAll();
|
}
|
|
protected override void OnAfterClose()
|
{
|
|
}
|
#endregion
|
|
protected override void LateUpdate()
|
{
|
base.LateUpdate();
|
|
if (Time.time > nextShowTime)
|
{
|
ExperienceGetBehaviour.Experience exp;
|
if (ExperienceGetBehaviour.GetExperience(out exp))
|
{
|
ExperienceFloat.Pattern _pattern;
|
if (exp.source == 4)
|
{
|
_pattern = ExperienceFloat.Pattern.LongFeng;
|
}
|
else
|
{
|
_pattern = ExperienceFloat.Pattern.Normal;
|
}
|
var experienceFloat = ExperienceFloatPool.Require(_pattern);
|
experienceFloat.SetActive(true);
|
experienceFloat.transform.SetParentEx(m_ResetPoint, Vector3.zero, Quaternion.identity, Vector3.one);
|
experienceFloat.Begin(exp.source, exp.value);
|
nextShowTime = Time.time + interval;
|
}
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|