DemoProductions / shmup

3 stars 2 forks source link

split enemy and movement scripts #60

Closed flip40 closed 8 years ago

flip40 commented 8 years ago

Split LinearEnemy into Enemy (probably a superclass for AI classes to inherit from in the long run) and an EnemyMovement Class. I added functionality in EnemyMovement class to allow modifying the linear movement by Sin or Cos waves. We could definitely go much further with defining movement inside of this class.

Our "LinearEnemy" was turned into a LinearEnemy prefab. I also added a couple other enemy examples (LinearWave and LinearCircular).

Also as a bit of an explanation on what is going on with the editor groups... Base Movement defines linear movement on x or y. This will not be modified. The X and Y modifier groups have their various changes added to the base x / y velocity, meaning that you can set a movement pattern, and still move it across the screen. The best example and explanation for this is in the LinearCircularEnemy prefab. The X and Y Modifier sections provide the necessary arguments for a perfect circular motion, however this perfect circle is happening locally. With no base X or Y velocity, it will do a circle, however if you apply a base X velocity of less than 1, the circle will move left across the screen. Maybe I should rename the sections to X / Y Additives? That might not be any clearer though.

ghost commented 8 years ago

A bit confused on how to the EnemyMovement script should work. I'm trying out the LinearCircularEnemy prefab and the x and y modifiers are in the 'none' state. When I try and modify the parameters and run the scene, the modifiers set themselves back to 'none'

Edit: Ah they can get modified while the scene is running though. May be something wrong here

flip40 commented 8 years ago

Are you sure you are using game objects that were created from and are linked to the prefabs? I did not upload the test.unity on this branch due to not wanting to overwrite your changes on the Weapon class that did make test.unity changes. If you are using the test.scene as is, the enemies there probably are not linked to the prefabs.

Otherwise not sure, they work fine from here (I just dragged a circular onto the scene and off he went). I also don't see git showing any diff on the prefabs after saving both the scene and project, so they should be the same prefabs already committed to the branch.

ghost commented 8 years ago

Something may have gone wrong while switching between branches. Let me try cloning into a new directory.

ghost commented 8 years ago

Dragged LinearCircularEnemy onto the scene (does not have any x or y modifiers) Hit play - Moves linearly - End play Adjusted some of the x and y modifiers on the LinearCircularEnemy game object on the scene Hit play - x and y modifiers back to 'none'

Not sure if I'm just misunderstanding the functionality of this. The x and y modifiers in LinearCircularEnemy should make it move in a squiggly depending on the sin, cos, etc params correct?

ghost commented 8 years ago

Oh. I was dragging the LinearCirEnemy prefab onto the scene and adjusting its params from the scene. Somehow it resets back to what the prefab's actual state is (which is 'none' for x and y modifiers). But if I modify the actual prefab, the state of the x and y modifiers stay as it should

There does seem to be something wrong here though, the LinCir and Wave prefabs don't have the x and y modifier values that they should

ghost commented 8 years ago

Other things: Do all enemies shoot? Currently each enemy shoots on each update Possibility for Movement class that EnemyMovement inherits from?

flip40 commented 8 years ago

Made an issue for me to remind me to check the prefabs on a new branch and see if these differences appear. You are right in that the behavior of the prefabs does still sound wrong.

Instead of base movement class, we might just rename enemy movement to movement. It isn't really enemy specific, it is just movement patterns... perhaps automated movement (differing from movement by input)?

Enemies all currently use Enemy class and shoot on update (which in effect is as fast as their weapon can fire). I was thinking of either using the Enemy class or another class to handle shooting patterns perhaps?