MiniMap
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Star : MonoBehaviour
|
||||
{
|
||||
private bool isActive;
|
||||
|
||||
private StarController starController;
|
||||
private int cost = 20;
|
||||
|
||||
[SerializeField] private GameObject starObject;
|
||||
|
||||
public int Cost
|
||||
{
|
||||
get
|
||||
{
|
||||
return cost;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsActive
|
||||
{
|
||||
get
|
||||
{
|
||||
return isActive;
|
||||
}
|
||||
set
|
||||
{
|
||||
isActive = value;
|
||||
starObject.SetActive(value);
|
||||
}
|
||||
}
|
||||
|
||||
public void init(StarController starController)
|
||||
{
|
||||
this.starController = starController;
|
||||
}
|
||||
|
||||
public void Buy(Player player)
|
||||
{
|
||||
player.coins -= cost;
|
||||
starController.SwitchStar();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b7a62849c96d20a429c376837b914ac0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,42 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class StarController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Star[] stars;
|
||||
|
||||
private int current = 0;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
foreach(Star s in stars)
|
||||
{
|
||||
s.init(this);
|
||||
}
|
||||
|
||||
Activate(current);
|
||||
current++;
|
||||
}
|
||||
|
||||
private void Activate(int idx)
|
||||
{
|
||||
for (int i = 0; i < stars.Length; i++)
|
||||
{
|
||||
if (i == idx)
|
||||
{
|
||||
stars[i].IsActive = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
stars[i].IsActive = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SwitchStar()
|
||||
{
|
||||
Activate(current);
|
||||
current++;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ad2085c2c2608de409aba3e03bfb32a3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user