In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces Unity3D how to achieve dessert Xiaoxiele game, the article introduces in great detail, has a certain reference value, interested friends must read!
Preface
Explanation:
Previously used ScreenToGif screencap, because the maximum uploaded .gif is not more than 5MB, so I did a lot of frame deletion and color weakening, which led to the color does not look very comfortable, do not stare at it for too long, otherwise it will be a little uncomfortable.
As the material used is ready-made, it does not take time and effort to pick, so the details may not be done very well.
Description:
Although this dessert Xiaoxie may seem simple and ordinary, it has somewhat increased the difficulty compared to the previous tank wars, and has been classified as an algorithm-level game.
Pull to the last look at the code, you can understand what I mean, all the code of the tank war is not as good as the code of the two classes, and the tank can only look at its back for other details.
If the tank war is low-level, then the dessert Xiaoxiele is medium-level, with a lot of animation and interaction (collision detection and dessert control, etc.), and all the mechanisms and functions of the game need to be manipulated on the model layer.
This time Xiaoxiele needs certain logical thinking, algorithm foundation, Unity comprehensive ability and programming foundation.
The square and round font and the glittering effects of Brin Brin will give the game a lovely wind atmosphere.
We divide the objects into model layer and render layer, so that they do their own job and reduce the coupling of work.
As there are still two courses and an examination left before the 12.29 th holiday, the deficiencies will be added later.
Project effect display
Project profile material presentation
Game resources (audio, pictures, special effects, etc.)
Scenes and packages (animation. Render sprites, controllers, etc.)
-1) {RemoveEntry (toBeRemovedEntry);} Rect btPosition = GUILayoutUtility.GetRect (m_AddButonContent, GUI.skin.button); const float addButonWidth = 200f; btPosition.x = btPosition.x + (btPosition.width-addButonWidth) / 2; btPosition.width = addButonWidth If (GUI.Button (btPosition, m_AddButonContent)) {ShowAddTriggermenu ();} serializedObject.ApplyModifiedProperties ();} private void RemoveEntry (int toBeRemovedEntry) {m_DelegatesProperty.DeleteArrayElementAtIndex (toBeRemovedEntry) } void ShowAddTriggermenu () {/ / Now create the menu, add items and show it GenericMenu menu = new GenericMenu (); for (int I = 0; I
< m_EventTypes.Length; ++i) { bool active = true; // Check if we already have a Entry for the current eventType, if so, disable it for (int p = 0; p < m_DelegatesProperty.arraySize; ++p) { SerializedProperty delegateEntry = m_DelegatesProperty.GetArrayElementAtIndex(p); SerializedProperty eventProperty = delegateEntry.FindPropertyRelative("eventID"); if (eventProperty.enumValueIndex == i) { active = false; } } if (active) menu.AddItem(m_EventTypes[i], false, OnAddNewSelected, i); else menu.AddDisabledItem(m_EventTypes[i]); } menu.ShowAsContext(); Event.current.Use(); } private void OnAddNewSelected(object index) { int selected = (int)index; m_DelegatesProperty.arraySize += 1; SerializedProperty delegateEntry = m_DelegatesProperty.GetArrayElementAtIndex(m_DelegatesProperty.arraySize - 1); SerializedProperty eventProperty = delegateEntry.FindPropertyRelative("eventID"); eventProperty.enumValueIndex = selected; serializedObject.ApplyModifiedProperties(); } }} Runtime-UIElements-ExecuteEvents.cs using System;using System.Collections.Generic;using UnityEngine.Pool; namespace UnityEngine.EventSystems{ public static class ExecuteEvents { public delegate void EventFunction(T1 handler, BaseEventData eventData); public static T ValidateEventData(BaseEventData data) where T : class { if ((data as T) == null) throw new ArgumentException(String.Format("Invalid type: {0} passed to event expecting {1}", data.GetType(), typeof(T))); return data as T; } private static readonly EventFunction s_PointerMoveHandler = Execute; private static void Execute(IPointerMoveHandler handler, BaseEventData eventData) { handler.OnPointerMove(ValidateEventData(eventData)); } private static readonly EventFunction s_PointerEnterHandler = Execute; private static void Execute(IPointerEnterHandler handler, BaseEventData eventData) { handler.OnPointerEnter(ValidateEventData(eventData)); } private static readonly EventFunction s_PointerExitHandler = Execute; private static void Execute(IPointerExitHandler handler, BaseEventData eventData) { handler.OnPointerExit(ValidateEventData(eventData)); } private static readonly EventFunction s_PointerDownHandler = Execute; private static void Execute(IPointerDownHandler handler, BaseEventData eventData) { handler.OnPointerDown(ValidateEventData(eventData)); } private static readonly EventFunction s_PointerUpHandler = Execute; private static void Execute(IPointerUpHandler handler, BaseEventData eventData) { handler.OnPointerUp(ValidateEventData(eventData)); } private static readonly EventFunction s_PointerClickHandler = Execute; private static void Execute(IPointerClickHandler handler, BaseEventData eventData) { handler.OnPointerClick(ValidateEventData(eventData)); } private static readonly EventFunction s_InitializePotentialDragHandler = Execute; private static void Execute(IInitializePotentialDragHandler handler, BaseEventData eventData) { handler.OnInitializePotentialDrag(ValidateEventData(eventData)); } private static readonly EventFunction s_BeginDragHandler = Execute; private static void Execute(IBeginDragHandler handler, BaseEventData eventData) { handler.OnBeginDrag(ValidateEventData(eventData)); } private static readonly EventFunction s_DragHandler = Execute; private static void Execute(IDragHandler handler, BaseEventData eventData) { handler.OnDrag(ValidateEventData(eventData)); } private static readonly EventFunction s_EndDragHandler = Execute; private static void Execute(IEndDragHandler handler, BaseEventData eventData) { handler.OnEndDrag(ValidateEventData(eventData)); } private static readonly EventFunction s_DropHandler = Execute; private static void Execute(IDropHandler handler, BaseEventData eventData) { handler.OnDrop(ValidateEventData(eventData)); } private static readonly EventFunction s_ScrollHandler = Execute; private static void Execute(IScrollHandler handler, BaseEventData eventData) { handler.OnScroll(ValidateEventData(eventData)); } private static readonly EventFunction s_UpdateSelectedHandler = Execute; private static void Execute(IUpdateSelectedHandler handler, BaseEventData eventData) { handler.OnUpdateSelected(eventData); } private static readonly EventFunction s_SelectHandler = Execute; private static void Execute(ISelectHandler handler, BaseEventData eventData) { handler.OnSelect(eventData); } private static readonly EventFunction s_DeselectHandler = Execute; private static void Execute(IDeselectHandler handler, BaseEventData eventData) { handler.OnDeselect(eventData); } private static readonly EventFunction s_MoveHandler = Execute; private static void Execute(IMoveHandler handler, BaseEventData eventData) { handler.OnMove(ValidateEventData(eventData)); } private static readonly EventFunction s_SubmitHandler = Execute; private static void Execute(ISubmitHandler handler, BaseEventData eventData) { handler.OnSubmit(eventData); } private static readonly EventFunction s_CancelHandler = Execute; private static void Execute(ICancelHandler handler, BaseEventData eventData) { handler.OnCancel(eventData); } public static EventFunction pointerMoveHandler { get { return s_PointerMoveHandler; } } public static EventFunction pointerEnterHandler { get { return s_PointerEnterHandler; } } public static EventFunction pointerExitHandler { get { return s_PointerExitHandler; } } public static EventFunction pointerDownHandler { get { return s_PointerDownHandler; } } public static EventFunction pointerUpHandler { get { return s_PointerUpHandler; } } public static EventFunction pointerClickHandler { get { return s_PointerClickHandler; } } public static EventFunction initializePotentialDrag { get { return s_InitializePotentialDragHandler; } } public static EventFunction beginDragHandler { get { return s_BeginDragHandler; } } public static EventFunction dragHandler { get { return s_DragHandler; } } public static EventFunction endDragHandler { get { return s_EndDragHandler; } } public static EventFunction dropHandler { get { return s_DropHandler; } } public static EventFunction scrollHandler { get { return s_ScrollHandler; } } public static EventFunction updateSelectedHandler { get { return s_UpdateSelectedHandler; } } public static EventFunction selectHandler { get { return s_SelectHandler; } } public static EventFunction deselectHandler { get { return s_DeselectHandler; } } public static EventFunction moveHandler { get { return s_MoveHandler; } } public static EventFunction submitHandler { get { return s_SubmitHandler; } } public static EventFunction cancelHandler { get { return s_CancelHandler; } } private static void GetEventChain(GameObject root, IList eventChain) { eventChain.Clear(); if (root == null) return; var t = root.transform; while (t != null) { eventChain.Add(t); t = t.parent; } } public static bool Execute(GameObject target, BaseEventData eventData, EventFunction functor) where T : IEventSystemHandler { var internalHandlers = ListPool.Get(); GetEventList(target, internalHandlers); // if (s_InternalHandlers.Count >0) / / Debug.Log ("Executinng" + typeof (T) + "on" + target); var internalHandlersCount = internalHandlers.Count; for (var I = 0; I
< internalHandlersCount; i++) { T arg; try { arg = (T)internalHandlers[i]; } catch (Exception e) { var temp = internalHandlers[i]; Debug.LogException(new Exception(string.Format("Type {0} expected {1} received.", typeof(T).Name, temp.GetType().Name), e)); continue; } try { functor(arg, eventData); } catch (Exception e) { Debug.LogException(e); } } var handlerCount = internalHandlers.Count; ListPool.Release(internalHandlers); return handlerCount >0;} / Execute the specified event on the first game object underneath the current touch. / private static readonly List s_InternalTransformList = new List (30); public static GameObject ExecuteHierarchy (GameObject root, BaseEventData eventData, EventFunction callbackFunction) where T: IEventSystemHandler {GetEventChain (root, s_InternalTransformList); var internalTransformListCount = swarm InternalTransformList.Count; for (var I = 0; I < internalTransformListCount; I +) {var transform = s _ InternalTransformList [I] If (Execute (transform.gameObject, eventData, callbackFunction) return transform.gameObject;} return null;} private static bool ShouldSendToComponent (Component component) where T: IEventSystemHandler {var valid = component is T; if (! valid) return false; var behaviour = component as Behaviour If (behaviour! = null) return behaviour.isActiveAndEnabled; return true;} / Get the specified object's event event. / / private static void GetEventList (GameObject go, IList results) where T: IEventSystemHandler {/ / Debug.LogWarning ("GetEventList"); if (results = = null) throw new ArgumentException ("Results array is null", "results"); if (go = = null | |! go.activeInHierarchy) return; var components = ListPool.Get () Go.GetComponents (components); var componentsCount = components.Count; for (var I = 0; I < componentsCount; iTunes +) {if (! ShouldSendToComponent (principals [I])) continue; / / Debug.Log (string.Format ("{2} found! On {0}. {1} ", go, sGetComponentsScratch [I] .GetType (), typeof (T)); results.Add [I] as IEventSystemHandler);} ListPool.Release (components); / / Debug.LogWarning (" end GetEventList ");} / Whether the specified game object will be able to handle the specified event. / / public static bool CanHandleEvent (GameObject go) where T: IEventSystemHandler {var internalHandlers = ListPool.Get (); GetEventList (go, internalHandlers); var handlerCount = internalHandlers.Count; ListPool.Release (internalHandlers); return handlerCount! = 0;} / Bubble the specified event on the game object, figuring out which object will actually receive the event. / / public static GameObject GetEventHandler (GameObject root) where T: IEventSystemHandler {if (root = = null) return null; Transform t = root.transform; while (t! = null) {if (CanHandleEvent (t.gameObject)) return t.gameObject; t = t.parent } return null;}} above is all the content of this article "how to realize dessert elimination game by Unity3D". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.