You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
86 lines
2.8 KiB
86 lines
2.8 KiB
4 years ago
|
using AX.InputSystem;
|
||
|
using AX.MessageSystem;
|
||
|
using AX.NetworkSystem;
|
||
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
|
||
|
public class AllotButton : BaseButton {
|
||
|
private Transform PowerScrollContent;
|
||
|
private Transform OwnerContent;
|
||
|
/// <summary>
|
||
|
/// 所选择的力量列表
|
||
|
/// </summary>
|
||
|
public static List<GameObject> SelectToAllot = new List<GameObject>();
|
||
|
/// <summary>
|
||
|
/// 选择的要分配给的用户Id
|
||
|
/// </summary>
|
||
|
public static long SelectUserId = 0;
|
||
|
/// <summary>
|
||
|
/// 现在所拥有的力量,总力量抛去已经分配出去的。
|
||
|
/// </summary>
|
||
|
public static List<GameObject> OwnerPowerNowList = new List<GameObject>();
|
||
|
/// <summary>
|
||
|
/// 该中队所拥有的所有力量
|
||
|
/// </summary>
|
||
|
public List<GameObject> AllPowerThisTeam = new List<GameObject>();
|
||
|
void Start()
|
||
|
{
|
||
|
PowerScrollContent = transform.parent.Find("PowerScrollView/Viewport/PowerScrollContent");
|
||
|
OwnerContent = transform.parent.Find("OwnerScrollView/Viewport/OwnerContent");
|
||
|
|
||
|
}
|
||
|
public override void RespondFun()
|
||
|
{
|
||
|
if (SelectUserId != 0 && SelectToAllot.Count > 0 )
|
||
|
{
|
||
|
List<long> alloPowers = new List<long>();
|
||
|
//保存所有被移交力量的gameObjID
|
||
|
foreach (GameObject powerObj in SelectToAllot)
|
||
|
{
|
||
|
alloPowers.Add(powerObj.GetComponent<CloneGameObjInfo>().gameObjID);
|
||
|
}
|
||
|
HandOverPair pair = new HandOverPair()
|
||
|
{
|
||
|
powers = alloPowers,
|
||
|
acceptedID = SelectUserId,
|
||
|
senderID = CurrentUserInfo.mySelf.Id
|
||
|
};
|
||
|
//取消所有物体的选中
|
||
|
MessageDispatcher.SendMessage("CANCEL_SELECTED_COMMAND", new CmdArgs());
|
||
|
//发给房间所有人
|
||
|
NetworkManager.Default.SendAsync("HAND_OVER_SYNC", pair);
|
||
|
//MessageDispatcher.SendMessage("HandOverUpdate");
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("已移交选中力量", 1);
|
||
|
//取消移交对象选择
|
||
|
SelectUserId = 0;
|
||
|
SelectToAllot.Clear();
|
||
|
MessageDispatcher.SendMessage("CancelAllocateSelectUserID");
|
||
|
}
|
||
|
else if(SelectUserId==0)
|
||
|
{
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("请选择移交对象", 1.5f);
|
||
|
}
|
||
|
else if (SelectToAllot.Count <= 0)
|
||
|
{
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("请选择移交力量", 1.5f);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
public class HandOverPair
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 被移交的力量
|
||
|
/// </summary>
|
||
|
public List<long> powers;
|
||
|
/// <summary>
|
||
|
/// 被移交的人员ID
|
||
|
/// </summary>
|
||
|
public long acceptedID;
|
||
|
/// <summary>
|
||
|
/// 移交人员的ID
|
||
|
/// </summary>
|
||
|
public long senderID;
|
||
|
}
|