Skip to content

Instantly share code, notes, and snippets.

@daleth90
Created Jul 26, 2017
Embed
What would you like to do?
using System.Collections.Generic;
using UnityEngine;
public class Armony {
private readonly List<Weapon> weapons;
private int currentIndex;
public Armony( List<Weapon> weapons ) {
this.weapons = weapons;
}
public void CooldownCurrentWeapon( float time ) {
weapons[ currentIndex ].Cooldown( time );
}
public void FireCurrentWeapon( Vector2 position, Vector2 direction ) {
weapons[ currentIndex ].Fire( position, direction );
}
public void SwitchRight() {
++currentIndex;
if ( currentIndex == weapons.Count ) {
currentIndex = 0;
}
}
public void SwitchLeft() {
--currentIndex;
if ( currentIndex == -1 ) {
currentIndex = weapons.Count - 1;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment