1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
using System;
using System.Collections.Generic;
using UnityEngine;
public class PlayerTab : MonoBehaviour
{
public ColorChip ColorTabPrefab;
public SpriteRenderer DemoImage;
public SpriteRenderer HatImage;
public SpriteRenderer SkinImage;
public SpriteRenderer PetImage;
public FloatRange XRange = new FloatRange(1.5f, 3f);
public FloatRange YRange = new FloatRange(-1f, -3f);
private HashSet<int> AvailableColors = new HashSet<int>();
private List<ColorChip> ColorChips = new List<ColorChip>();
private const int Columns = 3;
public void OnEnable()
{
PlayerControl.SetPlayerMaterialColors((int)PlayerControl.LocalPlayer.Data.ColorId, this.DemoImage);
PlayerControl.SetHatImage(SaveManager.LastHat, this.HatImage);
PlayerControl.SetSkinImage(SaveManager.LastSkin, this.SkinImage);
PlayerControl.SetPetImage(SaveManager.LastPet, (int)PlayerControl.LocalPlayer.Data.ColorId, this.PetImage);
float num = (float)Palette.PlayerColors.Length / 3f;
for (int i = 0; i < Palette.PlayerColors.Length; i++)
{
float x = this.XRange.Lerp((float)(i % 3) / 2f);
float y = this.YRange.Lerp(1f - (float)(i / 3) / num);
ColorChip colorChip = UnityEngine.Object.Instantiate<ColorChip>(this.ColorTabPrefab);
colorChip.transform.SetParent(base.transform);
colorChip.transform.localPosition = new Vector3(x, y, -1f);
int j = i;
colorChip.Button.OnClick.AddListener(delegate()
{
this.SelectColor(j);
});
colorChip.Inner.color = Palette.PlayerColors[i];
this.ColorChips.Add(colorChip);
}
}
public void OnDisable()
{
for (int i = 0; i < this.ColorChips.Count; i++)
{
UnityEngine.Object.Destroy(this.ColorChips[i].gameObject);
}
this.ColorChips.Clear();
}
public void Update()
{
this.UpdateAvailableColors();
for (int i = 0; i < this.ColorChips.Count; i++)
{
this.ColorChips[i].InUseForeground.SetActive(!this.AvailableColors.Contains(i));
}
}
private void SelectColor(int colorId)
{
this.UpdateAvailableColors();
if (this.AvailableColors.Remove(colorId))
{
SaveManager.BodyColor = (byte)colorId;
if (PlayerControl.LocalPlayer)
{
PlayerControl.LocalPlayer.CmdCheckColor((byte)colorId);
}
}
}
public void UpdateAvailableColors()
{
PlayerControl.SetPlayerMaterialColors((int)PlayerControl.LocalPlayer.Data.ColorId, this.DemoImage);
PlayerControl.SetPetImage(SaveManager.LastPet, (int)PlayerControl.LocalPlayer.Data.ColorId, this.PetImage);
for (int i = 0; i < Palette.PlayerColors.Length; i++)
{
this.AvailableColors.Add(i);
}
if (GameData.Instance)
{
List<GameData.PlayerInfo> allPlayers = GameData.Instance.AllPlayers;
for (int j = 0; j < allPlayers.Count; j++)
{
GameData.PlayerInfo playerInfo = allPlayers[j];
this.AvailableColors.Remove((int)playerInfo.ColorId);
}
}
}
}
|