Browse Source

Started making htings more OO

Josh_Dev_branch
Joshua Reason 4 years ago
parent
commit
4eee92e17e
12 changed files with 126 additions and 33 deletions
  1. +1
    -1
      Assets/Animations.meta
  2. +12
    -0
      Assets/Animations/CharacterController.controller
  3. +8
    -0
      Assets/Animations/CharacterController.controller.meta
  4. +4
    -0
      Assets/Scripts/Character.cs
  5. +11
    -1
      Assets/Scripts/GameMode/GameMode.cs
  6. +8
    -0
      Assets/Scripts/LevelBlocks.meta
  7. +58
    -0
      Assets/Scripts/LevelBlocks/ActiveBlock.cs
  8. +11
    -0
      Assets/Scripts/LevelBlocks/ActiveBlock.cs.meta
  9. +3
    -29
      Assets/Scripts/LevelBlocks/Block.cs
  10. +0
    -0
      Assets/Scripts/LevelBlocks/Block.cs.meta
  11. +9
    -1
      Assets/Scripts/Managers/GameManager.cs
  12. +1
    -1
      Assets/Scripts/Traps/ShootingCannon.cs

Assets/Plugins/IngameDebugConsole/Sprites.meta → Assets/Animations.meta View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: cb5d7b23a9e684a41a6a5d4f300eb1e6
guid: 452f251b75e8b1542a101f1ab882a3ba
folderAsset: yes
DefaultImporter:
externalObjects: {}

+ 12
- 0
Assets/Animations/CharacterController.controller View File

@ -0,0 +1,12 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!91 &9100000
AnimatorController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: CharacterController
serializedVersion: 5
m_AnimatorParameters: []
m_AnimatorLayers: []

+ 8
- 0
Assets/Animations/CharacterController.controller.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ed2a73208a872914f8187d96fb1f35e0
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 9100000
userData:
assetBundleName:
assetBundleVariant:

+ 4
- 0
Assets/Scripts/Character.cs View File

@ -7,6 +7,8 @@ using Networking.Server;
public class Character : MonoBehaviour
{
public enum Animation {Walk,Jump,Slide}
public string nextScene;
Animator characterAnimator;
public bool isTuteLevel = false;
@ -104,6 +106,8 @@ public class Character : MonoBehaviour
return new Vector3(0, y, 0);
}
public IEnumerator MoveToBlock(Block Target, Animation animation, float time)
IEnumerator JumpCoroutine(Block Target, Transform Current, float time, float heightMax)
{
float elapsedTime = 0;

+ 11
- 1
Assets/Scripts/GameMode/GameMode.cs View File

@ -73,6 +73,12 @@ public abstract class GameMode : ScriptableObject
/// <param name="allCharacters">List of all player Info</param>
protected virtual void OnAllPlayersMoved(PlayerData[] allPlayers) { }
/// <summary>
/// Called after all environmentblocks have taken their turn
/// </summary>
/// <param name="allPlayers">All players in scene</param>
protected virtual void OnEnvironmentTurn(PlayerData[] allPlayers) { }
/// <summary>
/// Called after one round has finished
/// </summary>
@ -93,7 +99,6 @@ public abstract class GameMode : ScriptableObject
public abstract bool isGameOver(PlayerData[] allPlayers);
public float GetRoundTime()
{
float retVal = gameTimes[0];
@ -156,6 +161,11 @@ public abstract class GameMode : ScriptableObject
AllPlayersMovedEvent?.Invoke();
}
public void EnvironmentTurn(PlayerData[] allPlayers)
{
OnEnvironmentTurn(allPlayers);
}
public void RoundEnd(PlayerData[] allPlayers)
{
OnRoundEnd(allPlayers);

+ 8
- 0
Assets/Scripts/LevelBlocks.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8884be0c8b5416f4ca24595d0f32dacb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

+ 58
- 0
Assets/Scripts/LevelBlocks/ActiveBlock.cs View File

@ -0,0 +1,58 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ActiveBlock : Block
{
protected List<PlayerData> currentPlayers = new List<PlayerData>();
#region Class Functions
/// <summary>
/// Is called after all players have taken one move
///
/// Should be implemented by a derived class
/// </summary>
public virtual void OnEnvironmentTurn(PlayerData[] allPlayers)
{
}
/// <summary>
/// Is called when a player moves onto this block
///
/// Should be implemented by a derived class
/// </summary>
/// <param name="player">Player which moved on to block</param>
public virtual void OnWalkedOnByPlayer(PlayerData player)
{
currentPlayers.Add(player);
}
/// <summary>
/// Is called when a player moves off of block
///
/// Should be implemented by a derived class
/// </summary>
/// <param name="player">Player which moved on to block</param>
public virtual void OnLeftByPlayer(PlayerData player)
{
currentPlayers.Remove(player);
}
/// <summary>
/// Called after all players have finished all their moves
///
/// Should be implemented by a derived class
/// </summary>
public virtual void OnRoundEnd(PlayerData[] allPlayers)
{
}
#endregion Class Functions
}

+ 11
- 0
Assets/Scripts/LevelBlocks/ActiveBlock.cs.meta View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c4346bd3c1435c747921b58965edffd3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Assets/Scripts/Block.cs → Assets/Scripts/LevelBlocks/Block.cs View File

@ -24,6 +24,7 @@ public class Block : MonoBehaviour
[Tooltip("Is this block at the bottom of a pit?")]
public bool isPit = false;
[Header("Spawn Settings")]
[Tooltip("Can this block be spawned on")]
public bool isSpawnable = false;
@ -58,36 +59,9 @@ public class Block : MonoBehaviour
}
/// <summary>
/// Is called after all players have taken one move
///
/// Should be implemented by a derived class
/// </summary>
public virtual void OnPlayersMoved()
{
}
/// <summary>
/// Is called when a player moves onto this block
///
/// Should be implemented by a derived class
/// </summary>
/// <param name="player">Player which moved on to block</param>
public virtual void OnWalkedOnByPlayer(PlayerData player)
{
}
/// <summary>
/// Called after all players have finished all their moves
///
/// Should be implemented by a derived class
/// </summary>
public virtual void OnRoundEnd()
{
}
#endregion Public Functions

Assets/Scripts/Block.cs.meta → Assets/Scripts/LevelBlocks/Block.cs.meta View File


+ 9
- 1
Assets/Scripts/Managers/GameManager.cs View File

@ -33,6 +33,7 @@ public class GameManager : MonoBehaviour
#region Private Variables
private Dictionary<int, PlayerData> playerData;
private List<ActiveBlock> activeBlocks;
#endregion Private Variables
#region Read Only
@ -51,7 +52,9 @@ public class GameManager : MonoBehaviour
private void Start()
{
//Start Game
//Find all active blocks
//#TODO don't use the find function
activeBlocks = FindObjectsOfType<ActiveBlock>().ToList();
StartCoroutine(GameRoutine());
}
@ -119,6 +122,11 @@ public class GameManager : MonoBehaviour
//Let Gamemode know all players have moved
gameMode.AllPlayersMoved(playerDataAsArray.ToArray());
//Tell each environment block to take a move
activeBlocks.ForEach(p => p.OnEnvironmentTurn(playerDataAsArray));
gameMode.EnvironmentTurn(playerDataAsArray);
playerDataAsArray.ForEach(p => p.client.SendScore()); //Update the players score
//if Game is over break out of loop

+ 1
- 1
Assets/Scripts/Traps/ShootingCannon.cs View File

@ -1,4 +1,4 @@
using System.Collections;
 using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;

Loading…
Cancel
Save