当前位置: 首页 > news >正文

网站 工信部备案 收回百度用户服务中心官网

网站 工信部备案 收回,百度用户服务中心官网,上海做什么赚钱快,域名注册了如何做网站上次用了unity3d做了一个,虽然用了MVP的的设计模式,但是把动作管理放在场景里让项目的耦合程度太高,所以应该把动作从场景类分离出来,场景只需要控制视图就可以了。(这都是我随便乱吹的,其实我也不清楚为什么要动作分离…

上次用了unity3d做了一个,虽然用了MVP的的设计模式,但是把动作管理放在场景里让项目的耦合程度太高,所以应该把动作从场景类分离出来,场景只需要控制视图就可以了。(这都是我随便乱吹的,其实我也不清楚为什么要动作分离)
盗用别人的uml图
这里写图片描述
1. 向上周的作业一样,先把场景构建好
basecode

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Com.MyGame;
namespace Com.MyGame
{public class Director : System.Object{private static Director _instance;public SceneController currentSceneController { get; set; }public static Director getInstance(){if (_instance == null){_instance = new Director();}return _instance;}}public interface SceneController{void loadResources();}
}

UserGUI

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Com.MyGame;public class UserGUI : MonoBehaviour
{public FirstController scene;public int status = 0;GUIStyle style;GUIStyle buttonStyle;float time = 60;float second = 0;void Start(){scene = Director.getInstance().currentSceneController as FirstController;style = new GUIStyle();style.fontSize = 40;style.alignment = TextAnchor.MiddleCenter;buttonStyle = new GUIStyle("button");buttonStyle.fontSize = 30;}private void Update(){scene.check_game_over();}void OnGUI(){second += Time.deltaTime / 2;if (second >= 1){time--;second = 0;}if (time > 0 && status == 0){GUI.Label(new Rect(Screen.width / 2 - 50, Screen.height / 2 - 85, 100, 50), time.ToString(), style);}if (status == 1 || time <= 0){GUI.Label(new Rect(Screen.width / 2 - 50, Screen.height / 2 - 85, 100, 50), "You Fail!", style);if (GUI.Button(new Rect(Screen.width / 2 - 70, Screen.height / 2, 140, 70), "Restart", buttonStyle)){status = 0;time = 60;second = 0;scene.restart();}}else if (status == 2){GUI.Label(new Rect(Screen.width / 2 - 50, Screen.height / 2 - 85, 100, 50), "You win!", style);if (GUI.Button(new Rect(Screen.width / 2 - 70, Screen.height / 2, 140, 70), "Restart", buttonStyle)){status = 0;time = 60;second = 0;scene.restart();}}}
}

FirtstController

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Com.MyGame;public class FirstController2 : MonoBehaviour, SceneController
{public CCActionManager actionManger { get; set; }public List<GameObject> LeftObjList { get; set; }public List<GameObject> RightObjList { get; set; }public GameObject[] boat_people { get; set; }Vector3 river_pos = new Vector3(0, 0, 0);public GameObject startShore { get; set; }public GameObject endShore { get; set; }public GameObject boat { get; set; }Vector3 startShorePos = new Vector3(11, 0.5f, 0);Vector3 endShorePos = new Vector3(-11, 0.5f, 0);Vector3 boatStartPos = new Vector3(4, 0.7f, 0);Vector3 boatEndPos = new Vector3(-4, 0.7f, 0);UserGUI userGUI;void Awake(){LeftObjList = new List<GameObject>();RightObjList = new List<GameObject>();boat_people = new GameObject[2];Director director = Director.getInstance();director.currentSceneController = this;userGUI = gameObject.AddComponent<UserGUI>() as UserGUI;loadResources();}public void loadResources(){GameObject river = Instantiate(Resources.Load("prefab/river", typeof(GameObject)), river_pos, Quaternion.identity, null) as GameObject;river.name = "river";startShore = Instantiate(Resources.Load("prefab/coast", typeof(GameObject)), startShorePos, Quaternion.identity, null) as GameObject;startShore.name = "startShore";endShore = Instantiate(Resources.Load("prefab/coast", typeof(GameObject)), endShorePos, Quaternion.identity, null) as GameObject;endShore.name = "endShore";boat = Instantiate(Resources.Load("prefab/boat", typeof(GameObject)), boatStartPos, Quaternion.identity, null) as GameObject;boat.name = "boat";boat.transform.parent = startShore.transform;GameObject priest, devil;for (int i = 0; i < 3; ++i){priest = Instantiate(Resources.Load("prefab/priest")) as GameObject;priest.name = i.ToString();priest.transform.position = new Vector3(7f + i * 1.5f, 2f, 0);priest.transform.parent = startShore.transform;LeftObjList.Add(priest);devil = Instantiate(Resources.Load("prefab/devil")) as GameObject;devil.name = (i + 3).ToString();devil.transform.position = new Vector3(7f + (i + 3) * 1.5f, 2f, 0);devil.transform.parent = startShore.transform;LeftObjList.Add(devil);}}public void check_game_over(){int start_priests = 0;int start_devil = 0;int end_priests = 0;int end_devil = 0;foreach(GameObject gb in LeftObjList){if (gb.transform.tag == "priest"){start_priests++;}else{start_devil++;}}foreach(GameObject gb in RightObjList){if (gb.transform.tag == "priest"){end_priests++;}else{end_devil++;}}foreach(GameObject gb in boat_people){if (gb == null)continue;if (boat.transform.parent == startShore .transform){if (gb.transform.tag == "priest"){start_priests++;}else{start_devil++;}}else{if (gb.transform.tag == "priest"){end_priests++;}else{end_devil++;}}}if (end_priests + end_devil == 6){userGUI.status = 2;return;}if ((start_priests < start_devil && start_priests > 0 )|| (end_priests < end_devil && end_priests > 0)){userGUI.status = 1;return;}userGUI.status = 0;}public void restart(){Application.LoadLevel(Application.loadedLevelName);}}
接下来就是动作管理了(主要是参考老师的ppt)
  1. 定义动作基类:使用 virtual 申明虚方法,通过重写实现多态。这样继承者就明确使用Start 和 Update 编程游戏对象行为,利用接口实现消息通知,避免与动作管理者直接依赖。
public class SSAction : ScriptableObject{public bool enable = true;public bool distroy = false;// Use this for initializationpublic GameObject gameObject { get; set; }public Transform transform { get; set; }public ISSActionCallback callback { get; set; }public virtual void Start(){throw new System.NotImplementedException();}// Update is called once per framepublic virtual void Update(){throw new System.NotImplementedException();}}

2.简单的动作实现(船移动,牧师魔鬼移动)

 public class CCMoveAction : SSAction{public Vector3 target;public float speed;public static CCMoveAction GetCCMoveAction(Vector3 target, float speed){CCMoveAction action = ScriptableObject.CreateInstance<CCMoveAction>();action.target = target;action.speed = speed;return action;}public override void Start(){}public override void Update(){this.transform.position = Vector3.MoveTowards(this.transform.position, target, speed * Time.deltaTime);if (this.transform.position == target){this.distroy = true;this.callback.SSActionEvent(this);}}}
  • 组合动作实现,组合动作可以用来定义一系列动作,让这一系列动作可以按顺序执行(借用了老师的代码)
 public class CCSequenceAction : SSAction, ISSActionCallback{public List<SSAction> sequence;public int repeat = -1;public int start = 0;public static CCSequenceAction GetSSAction(int repeat, int start, List<SSAction> sequence){CCSequenceAction action = ScriptableObject.CreateInstance<CCSequenceAction>();action.repeat = repeat;action.sequence = sequence;action.start = start;return action;}public override void Update(){if (sequence.Count == 0) return;if (start < sequence.Count){sequence[start].Update();}}public void SSActionEvent(SSAction source, SSActionEventType events = SSActionEventType.Competeted, int Param = 0, string strParam = null, Object objectParam = null){source.distroy = false;this.start++;if (this.start >= sequence.Count){this.start = 0;if (repeat > 0) repeat--;if (repeat == 0){this.distroy = true;this.callback.SSActionEvent(this);}}}// Use this for initializationpublic override void Start(){foreach (SSAction action in sequence){action.gameObject = this.gameObject;action.transform = this.transform;action.callback = this;action.Start();}}void OnDestory() { }}
  • 动作时间接口定义
 public enum SSActionEventType : int { Started, Competeted }public interface ISSActionCallback{void SSActionEvent(SSAction source, SSActionEventType events = SSActionEventType.Competeted,int intParam = 0, string strParam = null, Object objectParam = null);}
  • 动作管理器基类
public class SSActionManager : MonoBehaviour
{private Dictionary<int, SSAction> actions = new Dictionary<int, SSAction>();private List<SSAction> waitingAdd = new List<SSAction>();private List<int> waitingDelete = new List<int>();protected void Update(){foreach (SSAction ac in waitingAdd){actions[ac.GetInstanceID()] = ac;}waitingAdd.Clear();foreach (KeyValuePair<int, SSAction> kv in actions){SSAction ac = kv.Value;if (ac.distroy){waitingDelete.Add(ac.GetInstanceID());}else if (ac.enable){ac.Update();}}foreach (int key in waitingDelete){SSAction ac = actions[key];actions.Remove(key);DestroyObject(ac);}waitingDelete.Clear();}public void RunAction(GameObject gameobject, SSAction action, ISSActionCallback manager){action.gameObject = gameobject;action.transform = gameobject.transform;action.callback = manager;waitingAdd.Add(action);action.Start();}protected void Start() {}
  • 从动作管理器基类派生出一个类来管理具体过河动作
public class CCActionManager :SSActionManager, ISSActionCallback {public SSAction action1, action2;public CCSequenceAction sAction;public FirstController scene;float speed = 20f;void ISSActionCallback.SSActionEvent(SSAction source, SSActionEventType events, int intParam, string strParam, Object objectParam){}// Use this for initializationvoid Start () {scene = Director.getInstance().currentSceneController as FirstController;scene.actionManger = this;}// Update is called once per framevoid Update () {GameObject gameObj = null;base.Update();if (Input.GetMouseButtonDown(0)){Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);RaycastHit hit;if (Physics.Raycast(ray, out hit)) gameObj = hit.transform.gameObject;}if (gameObj != null){if (gameObj.transform.tag == "priest" || gameObj.transform.tag == "devil"){int seatNum, shoreNum;if (gameObj.transform.parent == scene.boat.transform.parent && (scene.boat_people[0] == null || scene.boat_people[1] == null)){seatNum = scene.boat_people[0] == null ? 0 : 1;if (gameObj.transform.parent == scene.startShore.transform){shoreNum = 0;for (int i = 0; i < scene.LeftObjList.Count; ++i){if (gameObj.name == scene.LeftObjList[i].name){getOnBoat(gameObj, shoreNum, seatNum);scene.LeftObjList.Remove(gameObj);}}}else{shoreNum = 1;for (int i = 0; i < scene.RightObjList.Count; ++i){if (gameObj.name == scene.RightObjList[i].name){getOnBoat(gameObj, shoreNum, seatNum);scene.RightObjList.Remove(gameObj);}}}scene.boat_people[seatNum] = gameObj;base.Update();gameObj.transform.parent = scene.boat.transform;}else if (gameObj.transform.parent == scene.boat.transform){shoreNum = scene.boat.transform.parent == scene.startShore.transform ? 0 : 1;seatNum =(scene.boat_people[0]!=null && scene.boat_people[0] == gameObj) ? 0 : 1;getOffBoat(gameObj, shoreNum);base.Update();scene.boat_people[seatNum] = null;if (shoreNum == 0){scene.LeftObjList.Add(gameObj);gameObj.transform.parent = scene.startShore.transform;}else{scene.RightObjList.Add(gameObj);gameObj.transform.parent = scene.endShore.transform;}}}else if(gameObj.transform.name == "boat"){if (scene.boat_people[0] != null || scene.boat_people[1] != null){moveBoat(scene.boat);scene.boat.transform.parent = scene.boat.transform.parent == scene.startShore.transform ?scene.endShore.transform : scene.startShore.transform;}}}scene.check_game_over();}public void moveBoat(GameObject boat){Vector3 pos = boat.transform.position == new Vector3(4, 0.7f, 0) ? new Vector3(-4, 0.7f, 0) : new Vector3(4, 0.7f, 0);action1 = CCMoveAction.GetCCMoveAction(pos, speed);this.RunAction(boat, action1, this);}public void getOnBoat(GameObject people, int shore, int seat){if (shore == 0 && seat == 0){action1 = CCMoveAction.GetCCMoveAction(new Vector3(3f, 2f, 0), speed);action2 = CCMoveAction.GetCCMoveAction(new Vector3(3f, 1.5f, 0), speed);}else if (shore == 0 && seat == 1){action1 = CCMoveAction.GetCCMoveAction(new Vector3(4.5f, 2f, 0), speed);action2 = CCMoveAction.GetCCMoveAction(new Vector3(4.5f, 1.5f, 0), speed);}else if (shore == 1 && seat == 0){action1 = CCMoveAction.GetCCMoveAction(new Vector3(-5f, 2f, 0), speed);action2 = CCMoveAction.GetCCMoveAction(new Vector3(-5f, 1.5f, 0), speed);}else if (shore == 1 && seat == 1){action1 = CCMoveAction.GetCCMoveAction(new Vector3(-3.5f, 2f, 0), speed);action2 = CCMoveAction.GetCCMoveAction(new Vector3(-3.5f, 1.5f, 0), speed);}CCSequenceAction saction = CCSequenceAction.GetSSAction(0, 0, new List<SSAction> { action1, action2 });this.RunAction(people, saction, this);}public void getOffBoat(GameObject people, int shoreNum){action1 = CCMoveAction.GetCCMoveAction(new Vector3(people.transform.position.x, 2f, 0), speed);if (shoreNum == 0) action2 = CCMoveAction.GetCCMoveAction(new Vector3(7 + 1.5f * System.Convert.ToInt32(people.name), 2f, 0), speed);else action2 = CCMoveAction.GetCCMoveAction(new Vector3(-7f - 1.5f * System.Convert.ToInt32(people.name), 2f, 0), speed);CCSequenceAction saction = CCSequenceAction.GetSSAction(0, 0, new List<SSAction> { action1, action2 });this.RunAction(people, saction, this);}
}

最后小小抱怨一句:实训已经开始了,希望潘老师在接下来几周呢手下留情一定


文章转载自:
http://budless.yqsq.cn
http://storekeeper.yqsq.cn
http://transparency.yqsq.cn
http://polymasty.yqsq.cn
http://aconitase.yqsq.cn
http://spunge.yqsq.cn
http://understandability.yqsq.cn
http://sax.yqsq.cn
http://cqd.yqsq.cn
http://stye.yqsq.cn
http://submandibular.yqsq.cn
http://dimashq.yqsq.cn
http://reargument.yqsq.cn
http://pentoxid.yqsq.cn
http://autistic.yqsq.cn
http://spirochaetal.yqsq.cn
http://karyogram.yqsq.cn
http://manxwoman.yqsq.cn
http://upc.yqsq.cn
http://chronic.yqsq.cn
http://processable.yqsq.cn
http://clipper.yqsq.cn
http://miscibility.yqsq.cn
http://pivotal.yqsq.cn
http://circumaviate.yqsq.cn
http://lingua.yqsq.cn
http://nuj.yqsq.cn
http://fighter.yqsq.cn
http://obtainable.yqsq.cn
http://intercoastal.yqsq.cn
http://aery.yqsq.cn
http://hydroquinone.yqsq.cn
http://hetty.yqsq.cn
http://descendible.yqsq.cn
http://carbonise.yqsq.cn
http://offtake.yqsq.cn
http://taegu.yqsq.cn
http://natatory.yqsq.cn
http://fe.yqsq.cn
http://lengthwise.yqsq.cn
http://flagging.yqsq.cn
http://rave.yqsq.cn
http://interstadial.yqsq.cn
http://approximate.yqsq.cn
http://transpose.yqsq.cn
http://forth.yqsq.cn
http://impalpable.yqsq.cn
http://prediabetes.yqsq.cn
http://truckload.yqsq.cn
http://iwis.yqsq.cn
http://leningrad.yqsq.cn
http://gct.yqsq.cn
http://patrolwoman.yqsq.cn
http://suburbanite.yqsq.cn
http://unpriest.yqsq.cn
http://explanatory.yqsq.cn
http://dymaxion.yqsq.cn
http://morale.yqsq.cn
http://autarchist.yqsq.cn
http://mountainside.yqsq.cn
http://capably.yqsq.cn
http://semimechanical.yqsq.cn
http://karikal.yqsq.cn
http://tamableness.yqsq.cn
http://inhabitant.yqsq.cn
http://nisei.yqsq.cn
http://topwork.yqsq.cn
http://karikal.yqsq.cn
http://shamois.yqsq.cn
http://chumar.yqsq.cn
http://dissected.yqsq.cn
http://acuminate.yqsq.cn
http://nightcap.yqsq.cn
http://totteringly.yqsq.cn
http://polyhydric.yqsq.cn
http://squawfish.yqsq.cn
http://mid.yqsq.cn
http://disimmure.yqsq.cn
http://concrescence.yqsq.cn
http://sulpician.yqsq.cn
http://flatly.yqsq.cn
http://aeropause.yqsq.cn
http://cytostome.yqsq.cn
http://foreignize.yqsq.cn
http://wrongly.yqsq.cn
http://artist.yqsq.cn
http://interpretation.yqsq.cn
http://antimissile.yqsq.cn
http://eclair.yqsq.cn
http://overland.yqsq.cn
http://mastoiditis.yqsq.cn
http://unexacting.yqsq.cn
http://stillborn.yqsq.cn
http://overspray.yqsq.cn
http://tangerine.yqsq.cn
http://commandable.yqsq.cn
http://makeup.yqsq.cn
http://twicer.yqsq.cn
http://moneylender.yqsq.cn
http://technophobia.yqsq.cn
http://www.dt0577.cn/news/79559.html

相关文章:

  • 宝安的医院网站建设百度sem竞价推广
  • 在哪个网站做劳动用工备案百度官方网首页
  • wordpress主题ruikedu关键词优化推广排名多少钱
  • 快推达seo关键词排名快照优化
  • 莘县网站建设cpv广告联盟
  • 外贸企业网站模版百度关键词优化技巧
  • 网站建设在线seo软件哪个好
  • 福州医社保增减员在什么网站做如何自己制作网站
  • 长春网站建设于健网络营销是做什么的
  • 做一个展示型网站多少钱最近一周的时政热点新闻
  • h5做招聘网站西安百度推广外包
  • 做网站需要后端吗营销计划
  • 好用的h5网站模板下载亚马逊的免费网站
  • 网站备案为什么要关闭新闻稿范文
  • 怎样在自己的网站上家程序优化网站排名需要多少钱
  • 移除wordpress上边栏百度seo优化服务
  • javaweb做视频网站难吗重庆seo主管
  • wordpress插入pdfseo排名第一的企业
  • 做电影网站多少钱百度app官方下载安装
  • 如何建设一个完整的网站宁波网站制作与推广价格
  • 网站备案表格下载教育培训机构管理系统
  • 做网站名词一站传媒seo优化
  • 程序开发步骤seo怎么搞
  • 网站开发需要什么技术最近有哪些新闻
  • 做微信的网站有哪些功能广告的六种广告形式
  • 在一家传媒公司做网站编辑 如何竞价推广营销
  • 青岛北京网站建设公司网站开发北京公司
  • 公众号兼职网站开发推广方案经典范文
  • 北京律师网站建设策划方案网站
  • html怎么做网站版块百度云盘登录电脑版