How do I use Extends to update a subclass from its parent?
I am currently making a 2-d platformer mario-style unity game for college in which we are supposed to use multiple design patterns. Now at the moment, I am busy making a prototype pattern (which to my understanding is a pattern from which all "enemies" could extend from to reuse certain codes or functions.
When I try to extend a class from another class, however, it does not recognize "extends".
Is there something I am missing out on? I though the ':' in the class names is equal to "Implements", am I wrong about this?
I simply need to know how I let a class extend from another class, meaning it literally uses the methods in that class.
Here is the class from which I am trying to extend: using UnityEngine; using System.Collections;
public abstract class Prototype : MonoBehaviour {
int eHealth;
int eScore;
IMoveForward moveForward;
ILookForward lookForward;
public void SetMoveBehaviour(IMoveForward m)
{
this.moveForward = m;
}
public void SetLookBehaviour(ILookForward l)
{
this.lookForward = l;
}
//void SetJumpBehaviour()
public int Health
{
get { return eHealth; }
set { eHealth = value; }
}
public int Score
{
get { return eScore; }
set { eScore = value; }
}
void Update()
{
SetLookBehaviour(lookForward);
SetMoveBehaviour(moveForward);
}
// public abstract Prototype Clone();
}
And here is the class which is supposed to extend from said class:
using UnityEngine;
using System.Collections;
using System;
class BasicMovement : Prototype, IMoveForward {
public float _speed = .5f;
//send the speed value to the move interface
public float speed
{
get
{
return _speed;
}
set
{
_speed = value;
}
}
//implement the movement method
public void MoveCharacter(Vector2 m)
{
m = new Vector2(transform.localScale.x, 0) * speed;
}
}
This class also implements an interface called (IMoveForward) (assuming ":" is actually "implements").
Sorry if I'm being somewhat vague it's just that I am not sure what I am supposed to do. right now the classes mentioned above are all working without errors, but I have no update function (which i would like to put in the Prototype class and from there update everything)
Please let me know if I need to specify more things, and basically what I am mostly trying to ask is: How can I extend from another class, so I can update the subclass through the extended class?
Thank you for your time and once again, let me know if I need to specify things.