public static Swarm GenerateSwarmWithShape(shipType type, int size, float moveSpeed, float moveVariance, float spawnVariance, swarmTargetType targetType, swarmActionShape shape) { List <SwarmPathAction> actions = new List <SwarmPathAction> (); List <Object> enemies = new List <Object> (); Object parent = null; Vector3 start = new Vector3(-7, 11, 0); switch (shape) { case swarmActionShape.figureEight: actions = FigureEight(moveSpeed, moveVariance, targetType); break; case swarmActionShape.diamond: actions = Diamond(moveSpeed, moveVariance, targetType); break; case swarmActionShape.circle: actions = Circle(moveSpeed, moveVariance, targetType); break; case swarmActionShape.laces: actions = Laces(moveSpeed, moveVariance, targetType); break; case swarmActionShape.arcswoop: actions = ArcSwoop(moveSpeed, moveVariance, targetType); break; } //check for errors, incompatabailities: foreach (SwarmPathAction action in actions) { if (action.moveDetails != null) { if (action.moveDetails.moveActionType == swarmMoveActionType.bezier && action.moveDetails.moveTargetVariance != 0) { // throw new System.ArgumentException("Swarm Path includes a bezier curve with non-zero moveTargetVariance"); } } } for (int i = 0; i < size; i++) { enemies.Add( Resources.Load(type.ToString()) ); } if (enemies.Count == 1) { enemies.Add( Resources.Load(shipType.dummy.ToString()) ); parent = enemies[1]; } return(new Swarm(enemies, actions, start, spawnVariance, parent)); }
// Use this for initialization public Ship(shipType _shipType, float _maxHealth, float _shipSpeed = 0, bool _playerShip = false) { shipSpeed = _shipSpeed; shipType = _shipType; maxHealth = _maxHealth; currentHealth = _maxHealth; weapons = new Weapon[5]; playerShip = _playerShip; }
public void selectTank() { AudioPlayer.menuClick.Play(); chosenType = shipType.tank; player = Instantiate(playerPrefab, levels[curLevel - 1].GetComponent <LevelBehavior>().levelOrigin.transform.position + new Vector3(0, 0, 5), levels[curLevel - 1].GetComponent <LevelBehavior>().levelOrigin.transform.rotation, null); firstLoad = false; ShipSelectScreenObj.SetActive(false); }
// Update is called once per frame void Update() { colorState = GameObject.Find("mainBarrel").GetComponent <shootingScript>(); if (colorState.shipCurrent == shootingScript.shipType.Red) { shipCurrent = shipType.Red; } if (colorState.shipCurrent == shootingScript.shipType.Blue) { shipCurrent = shipType.Blue; } if (colorState.shipCurrent == shootingScript.shipType.Green) { shipCurrent = shipType.Green; } // Ship shooting with different colors if (Input.GetKey(KeyCode.UpArrow)) { if (shipCurrent == shipType.Red && Time.time > nextFire) { nextFire = Time.time + fireRate; RedAtk(); } else if (shipCurrent == shipType.Green) { GrenAtk(); } } if (Input.GetKeyDown(KeyCode.UpArrow)) { if (shipCurrent == shipType.Blue) { BluAtk(); } } }
public Ship(int _shipID, shipType _type, GameObject _shipGO) { shipID = _shipID; type = _type; shipGO = _shipGO; }
// Update is called once per frame void Update() { RedBallrate = GameObject.FindObjectOfType <shootingScript>() as shootingScript; spreadShotScript[] RedBallSpread = GameObject.FindObjectsOfType <spreadShotScript>() as spreadShotScript[]; if (Input.GetKeyDown(KeyCode.LeftArrow)) { shipCurrent = shipType.Red; shipModel.gameObject.GetComponent <SpriteRenderer>().color = shipColors[0]; } if (Input.GetKeyDown(KeyCode.DownArrow)) { shipCurrent = shipType.Blue; shipModel.gameObject.GetComponent <SpriteRenderer>().color = shipColors[1]; } if (Input.GetKeyDown(KeyCode.RightArrow)) { shipCurrent = shipType.Green; shipModel.gameObject.GetComponent <SpriteRenderer>().color = shipColors[2]; } // Ship shooting with different colors if (Input.GetKey(KeyCode.UpArrow)) { if (shipCurrent == shipType.Red && Time.time > nextFire) { nextFire = Time.time + fireRate; muzzleTypes[0].enabled = true; RedAtk(); } else if (shipCurrent == shipType.Green) { muzzleTypes[2].enabled = true; GrenAtk(); } } if (Input.GetKeyDown(KeyCode.UpArrow)) { if (shipCurrent == shipType.Blue) { muzzleTypes[1].enabled = true; BluAtk(); } } if (Input.GetKeyUp(KeyCode.UpArrow)) { muzzleTypes[0].enabled = false; muzzleTypes[1].enabled = false; muzzleTypes[2].enabled = false; } //Spread shot debug key if (Input.GetKeyDown(KeyCode.Space)) { Barrels[0].gameObject.GetComponent <spreadShotScript>().enabled = true; Barrels[1].gameObject.GetComponent <spreadShotScript>().enabled = true; } //Weapon Steroids debug //red if (Input.GetKeyDown(KeyCode.Alpha1)) { RedBallrate.fireRate -= 1f; RedBallSpread[0].fireRate -= 1f; RedBallSpread[1].fireRate -= 1f; Red_Ball.Speed += 5f; Red_Ball.bulletWidth += 1f; } //blue if (Input.GetKeyDown(KeyCode.Alpha2)) { Blue_Laser.maxLaserScale += 1f; Blue_Laser.laserSpeed += 1f; Blue_Laser.laserWidth += 1f; } //green if (Input.GetKeyDown(KeyCode.Alpha3)) { Green_Ball.Speed += 1f; Green_Ball.explosionSize += 1f; Green_Ball.explosionSpeed += 1f; } }
// Use this for initialization void Start() { shipCurrent = shipType.Red; shipModel.gameObject.GetComponent <SpriteRenderer>().color = shipColors[0]; }
// Use this for initialization void Awake() { gameCamera = GameObject.Find("Main Camera").GetComponent <Camera>(); ship = new Ship(shipType, maxHealth, shipSpeed); ship.dodgeSpeed = dodgeSpeed; ship.dodgeLength = dodgeLength; ship.weapons [0] = Weapon.createBasicEnemyWeapon(); ship.isComponent = isComponent; ship.componentType = componentType; //instantiate weapons based on ship type switch (shipType) { case shipType.fighter: break; case shipType.frigate: ship.weapons [0] = Weapon.createFrigateSpreadWeapon(); break; } if (componentCount > 0) { //spawn in components string resourcePath = ""; switch (shipType) { case shipType.frigate: resourcePath = "frigate_components/"; break; } //right now we only support 2 components per ship - 1 left and 1 right var values = componentType.GetValues(typeof(componentType)); componentType left = (componentType)values.GetValue(Random.Range(0, values.Length)); componentType right = (componentType)values.GetValue(Random.Range(0, values.Length)); //totally janky Object LeftComponent = Resources.Load(resourcePath + "left_" + left.ToString()); components.Add(LeftComponent); Object RightComponent = Resources.Load(resourcePath + "right_" + right.ToString()); components.Add(RightComponent); foreach (Object component in components) { //initialize component properties GameObject newComponent = Instantiate(component) as GameObject; newComponent.GetComponent <EnemyFighterAI> ().isComponent = true; newComponent.transform.parent = this.transform; switch (newComponent.GetComponent <EnemyFighterAI> ().componentType) { case componentType.shield: shipType type = this.ship.shipType; Object shield = null; GameObject newShield = null; switch (type) { case shipType.frigate: shield = Resources.Load(resourcePath + "shield"); break; } newShield = Instantiate(shield) as GameObject; newShield.transform.parent = newComponent.transform; //set sheild and generator to both have null weapons newShield.GetComponent <EnemyFighterAI> ().ship.weapons = null; this.weapons = null; break; case componentType.missile: newComponent.GetComponent <EnemyFighterAI> ().ship.weapons [0] = Weapon.createBasicEnemymissile(); break; case componentType.rail: newComponent.GetComponent <EnemyFighterAI> ().ship.weapons [0] = Weapon.createBasicEnemyRail(); break; } //if its a right component change the weapon offset to be -x if (newComponent.name.Contains("left") && newComponent.GetComponent <EnemyFighterAI> ().ship.weapons.Length > 0) { foreach (Weapon weapon in newComponent.GetComponent <EnemyFighterAI> ().ship.weapons) { if (weapon != null) { foreach (FireStream firestream in weapon.fireStreams) { firestream.offset = new Vector3(-firestream.offset.x, firestream.offset.y); } } } } } } }
public Ship(int _shipID, shipType _type, GameObject _shipGO) { shipID = _shipID; type = _type; shipGO = _shipGO; }