blob: a0cfe5235c911965d4bb77398bbdff3cd58cedb3 (
plain)
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
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public partial class PlayerManager : Singleton<PlayerManager>
{
// 持有的物品
public List<ItemBase> items { get { return m_Items; } }
private List<ItemBase> m_Items = new List<ItemBase>();
// 当前选中的物品
ItemBase m_CurrentItem = null;
void InitItems()
{
m_Items.Add(new Item_B2Phone());
m_Items.Add(new Item_SpaceBeamer());
}
/// <summary>
/// 选中物品
/// </summary>
public void SetCurrentItem(ItemBase item)
{
if (!items.Contains(item))
{
Debug.LogError("No such item");
return;
}
m_CurrentItem = item;
}
/// <summary>
/// 使用当前道具
/// </summary>
public void UseCurrentItem()
{
if (m_CurrentItem == null)
return;
m_CurrentItem.OnUse(m_Crew.gameObject);
}
void UpdateItems()
{
for(int i = 0; i < items.Count; ++i)
{
items[i].Update();
}
}
}
|