Skip to content
This repository was archived by the owner on Jan 25, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Binary file modified Assets/Materials/Blue.mat
Binary file not shown.
Binary file modified Assets/Materials/Brown.mat
Binary file not shown.
Binary file modified Assets/Materials/BuildingGlass.mat
Binary file not shown.
Binary file modified Assets/Materials/BuildingGrey.mat
Binary file not shown.
Binary file modified Assets/Materials/BuildingMetal.mat
Binary file not shown.
Binary file modified Assets/Materials/BuildingStone.mat
Binary file not shown.
Binary file modified Assets/Materials/BuildingWhite.mat
Binary file not shown.
Binary file modified Assets/Materials/Dust.mat
Binary file not shown.
Binary file modified Assets/Materials/Green.mat
Binary file not shown.
Binary file modified Assets/Materials/OilDrums.mat
Binary file not shown.
Binary file modified Assets/Materials/Red.mat
Binary file not shown.
Binary file modified Assets/Materials/TankColour.mat
Binary file not shown.
Binary file modified Assets/Materials/TankGrey.mat
Binary file not shown.
Binary file modified Assets/Materials/TankLights.mat
Binary file not shown.
Binary file modified Assets/Materials/YellowDark.mat
Binary file not shown.
Binary file modified Assets/Materials/YellowLight.mat
Binary file not shown.
Binary file added Assets/Prefabs/Tank 1.prefab
Binary file not shown.
7 changes: 7 additions & 0 deletions Assets/Prefabs/Tank 1.prefab.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Scenes/GameScene1.unity
Binary file not shown.
7 changes: 7 additions & 0 deletions Assets/Scenes/GameScene1.unity.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/Scripts/Scripts OutScal.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions Assets/Scripts/Scripts OutScal/TankController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TankController
{
private TankModel tankModel;
private TankView tankView;
public Rigidbody rigidbody;

public TankController (TankModel _tankModel, TankView _tankView)
{
tankModel = _tankModel;
tankView = GameObject.Instantiate<TankView>(_tankView); ;
rigidbody = tankView.GetRigidBody();

tankModel.SetTankController(this);
tankView.SetTankController(this);

tankView.ChangeColor(tankModel.color);
}

public void Move(float movement, float movement_speed)
{
rigidbody.velocity = tankView.transform.forward * movement * movement_speed;
}
public void Rotate(float rotation, float rotate_speed)
{
Vector3 vector = new Vector3(0f, rotation*rotate_speed, 0f);
Quaternion deltaRotation = Quaternion.Euler(vector * Time.deltaTime);
rigidbody.MoveRotation(rigidbody.rotation * deltaRotation);
}
public TankModel GetTankModel()
{
return tankModel;
}
}

11 changes: 11 additions & 0 deletions Assets/Scripts/Scripts OutScal/TankController.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions Assets/Scripts/Scripts OutScal/TankModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TankModel
{
public float movement_speed;
public float rotation_speed;
private TankController tankController;
public TankTypes tankTypes;
public Material color;
// Start is called before the first frame update
void Start()
{

}

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

}
public TankModel(float _movement, float _rotation, TankTypes tank, Material _color)
{
movement_speed = _movement;
rotation_speed = _rotation;
tankTypes = tank;
color = _color;
}

public void SetTankController (TankController _tankController)
{
tankController = _tankController;
}


}
11 changes: 11 additions & 0 deletions Assets/Scripts/Scripts OutScal/TankModel.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions Assets/Scripts/Scripts OutScal/TankSelection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TankSelection : MonoBehaviour
{
public TankSpawner tankSpawner;
public void BlueTankSelected()
{
Debug.Log("Blue Tank Selected");
tankSpawner.CreateTank(TankTypes.BlueTank);
this.gameObject.SetActive(false);
}
public void RedTankSelected()
{
tankSpawner.CreateTank(TankTypes.RedTank);
this.gameObject.SetActive(false);
}
public void GoldTankSelected()
{
tankSpawner.CreateTank(TankTypes.GreenTank);
this.gameObject.SetActive(false);
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/Scripts OutScal/TankSelection.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions Assets/Scripts/Scripts OutScal/TankSpawner.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TankSpawner : MonoBehaviour
{
[System.Serializable]
public class Tank
{
public float movementSpeed;
public float rotationSpeed;
public TankTypes tankType;
public Material color;

}

public List<Tank> tankList;

public TankView tankView;
// Start is called before the first frame update
void Start()
{

}

public void CreateTank(TankTypes tankType)
{
//ByDefault Green Tank will come
if (tankType == TankTypes.BlueTank)
{
TankModel tankModel = new TankModel(tankList[1].movementSpeed, tankList[1].rotationSpeed, tankList[1].tankType, tankList[1].color);
TankController tankController = new TankController(tankModel, tankView);
}
else if (tankType == TankTypes.GreenTank)
{
TankModel tankModel = new TankModel(tankList[0].movementSpeed, tankList[0].rotationSpeed, tankList[0].tankType, tankList[0].color);
TankController tankController = new TankController(tankModel, tankView);
}
else if (tankType == TankTypes.RedTank)
{
TankModel tankModel = new TankModel(tankList[2].movementSpeed, tankList[2].rotationSpeed, tankList[2].tankType, tankList[2].color);
TankController tankController = new TankController(tankModel, tankView);
}


}

}
11 changes: 11 additions & 0 deletions Assets/Scripts/Scripts OutScal/TankSpawner.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions Assets/Scripts/Scripts OutScal/TankTypes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public enum TankTypes
{
GreenTank,
BlueTank,
RedTank
}
11 changes: 11 additions & 0 deletions Assets/Scripts/Scripts OutScal/TankTypes.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 59 additions & 0 deletions Assets/Scripts/Scripts OutScal/TankView.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TankView : MonoBehaviour
{
private float movement;
private float rotation;
public Rigidbody rigidBody;
public MeshRenderer[] childs;

private TankController tankController;
// Start is called before the first frame update
void Start()
{
GameObject Camera = GameObject.Find("Main Camera");
Camera.transform.SetParent(transform);
Camera.transform.position = new Vector3(-42f, 40f, -25f);

}

// Update is called once per frame
void Update()
{
Movement();
if (movement!= 0)
tankController.Move(movement, tankController.GetTankModel().movement_speed);

if (rotation!= 0)
tankController.Rotate(rotation, tankController.GetTankModel().rotation_speed);
}

private void Movement()
{
movement = Input.GetAxis("Vertical");
rotation = Input.GetAxis("Horizontal");
}

public TankView()
{

}
public void SetTankController(TankController _tankController)
{
tankController = _tankController;
}
public Rigidbody GetRigidBody()
{
return rigidBody;
}
public void ChangeColor(Material color)
{
for (int i = 0; i < childs.Length; i++)
{
childs[i].material = color;
}
}

}
11 changes: 11 additions & 0 deletions Assets/Scripts/Scripts OutScal/TankView.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading