码迷,mamicode.com
首页 > 其他好文 > 详细

点击NPC改变鼠标图标

时间:2015-05-21 10:26:25      阅读:105      评论:0      收藏:0      [点我收藏+]

标签:

基类:

using UnityEngine;
using System.Collections;

public class CommonNPC : MonoBehaviour {

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}

    void OnMouseEnter()
    {
        MouseCursor._instance.SetCursorDialog();
    }
    void OnMouseExit()
    {
        MouseCursor._instance.SetCursorHand();
    }
}

  

 

子类:

using UnityEngine;
using System.Collections;

public class NPCTask : CommonNPC
{
    public TweenPosition TweenPos;
    public GameObject ConfirmButton;
    public GameObject CancelButton;
    public GameObject FinishButton;
    public UILabel Label;
    public int KilledAnimals;
    private bool IsTasking;
	// Use this for initialization
	void Start () {
        IsTasking = false;
        KilledAnimals = 0;
        FinishButton.SetActive(false);
	}

	void OnMouseOver()
    {
        if (Input.GetMouseButtonDown(0))
        {
            TweenPos.gameObject.SetActive(true);
            TweenPos.PlayForward();
            if(IsTasking==false)//接收任务
            {
                Label.text = "任务:杀死10个动物\n奖励:1000金币" ;
                FinishButton.SetActive(false);
                ConfirmButton.SetActive(true);
                CancelButton.SetActive(true);
            }
            else//提交任务
            {
                Label.text = "已经杀死" + KilledAnimals + "个动物";
                FinishButton.SetActive(false);
                ConfirmButton.SetActive(true);
                CancelButton.SetActive(true);
            }

        }
    }
    public void OnClickConfirm()//接收任务
    {
        Label.text = "已经杀死" + KilledAnimals + "个动物";
        FinishButton.SetActive(false);
        ConfirmButton.SetActive(true);
        CancelButton.SetActive(true);
        IsTasking = true;
    }
    public void OnClickCancel()
    {
        TweenPos.PlayReverse();
    }
    public void OnClickFinish()//提交任务
    {
        if(KilledAnimals>=10)
        {
            //
        }
    }

	// Update is called once per frame
	void Update () {
	
	}
}

  

点击NPC改变鼠标图标

标签:

原文地址:http://www.cnblogs.com/notlate/p/4518864.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!