using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class cube : MonoBehaviour {
// Use this for initialization
void Start () {
NotificationCenter.Instance.RegistObserver("CubeAngry",ScaleSelf);
}
// Update is called once per frame
void Update () {
}
public void ScaleSelf(MesageInfo mesage)
{
transform.localScale = Vector3.one * (int)mesage.Alist[0];
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class sphere : MonoBehaviour
{
MesageInfo mesage;
void Awake()
{
NotificationCenter.Instance.RegistObserver("SphereAngry", ChangeColor);
NotificationCenter.Instance.RegistObserver("SphereMove", Move);
}
public void ChangeColor(MesageInfo mesage)
{
GetComponent<MeshRenderer>().material.color = (Color)mesage.Alist[0];
}
public void Move(MesageInfo mesage)
{
transform.position += transform.forward * (float)mesage.Alist[0];
}
}
网友评论