Skip to content

Unity Project in Top Down style to demonstrate the correct use of all aspects of OOP and construct an easily customizable system of behaviors for certain objects (in this case, primitives).

License

Notifications You must be signed in to change notification settings

EpicSharpCode/TopdownManipulation

Repository files navigation

TopdownManipulation

In this code challenge I create a Unity Project (hereinafter called "game") in TopDown style to demonstrate the correct use of all aspects of OOP and construct an easily customizable system of behaviors for certain objects (in this case, primitives).

Introduction

The development of the code for this game can be taken into 4 main directions:

  1. Primitives
  2. Behaviors
  3. Raycast Input
  4. Manipulation Controller
  5. UI Controller (with World Space Canvas feature)

Primitives

Primitives were created using the common abstract class Primitive from which different types of primitives are subsequently inherited. Abstract class Primitive implements the methods of the IBehaviourHandler interface.

The game contains the implementation of three primitives:

  • Cube
  • Cylinder
  • Sphere

Behaviours

Each specific behavior (for example, GreenColorMaterialBehaviour) inherits from an abstract specific behavior class (for example, ColorMaterialBehaviour), which inherits from a general abstract behavior class BehaviourBase. Abstract class BehaviourBase implements the methods of the IBehaviour interface.

The game contains the implementation of three behaviors:

  1. Changing the color of a primitive (ColorMaterialBehaviour)
    • GreenColorMaterialBehaviour for static green color
  2. Сolor pulsation of a primitive (PulseColorBehaviour)
    • RedPulseColorBehaviour for pulse red color
  3. Movement of a primitive (MovementBehaviour)
    • UpMovementBehaviour for loop movement of primitive

Each behavior has a custom version of the behavior (for example, CustomMovementBehaviour), which is configured through the inspector. It is created for each behavior to show the flexibility of the created system and its adaptation to various cases.

Raycast Input

The raycast input system is represented by the RaycastInput class. This class is added as a component to an empty GameObject. This class registers all rays within the shared “Primitives” layer (configured in the inspector of this component).

The RaycastInput class scans (raycasts) the game space and sends requests through static calls to a class MatipulationController that defines the manipulation of all main scene GameObjects and their components (UI_Controller and CameraControl)

Manipulation Controller

The ManipulationController class controls the camera (CameraControl) and the UI Controller (UI_Controller). This allows you to control the system for “selecting” a specific primitive and make corresponding calls to methods in the scripts mentioned above.

UI Controller

The UI System consists of the controller class UI_Controller and that class is assigned to an empty GameObject and configured on the scene for the functioning of any implementation of World Space Canvas.

The abstract class UI_WorldSpaceCanvas manages the state of each canvas instance of inherited class and is responsible for the basic functionality (Show, Hide, Canvas Group and etc)

The SelectBehaviourCanvas prefab contains the UI_SelectBehaviourCanvas script. The prefab also contains a panel with buttons to control the behavior of the primitives. All button behavior (onClick) is set by UI_SelectBehaviourClass by adding delegates to the list of listeners.

About

Unity Project in Top Down style to demonstrate the correct use of all aspects of OOP and construct an easily customizable system of behaviors for certain objects (in this case, primitives).

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published