Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package{
- import flash.display.MovieClip;
- import playerio.*
- import flash.text.TextField;
- import flash.text.TextFieldType;
- import flash.events.KeyboardEvent;
- import flash.text.TextFormat;
- import flash.net.FileReference;
- import flash.net.URLRequest;
- import flash.events.Event;
- import flash.events.ProgressEvent;
- import flash.display.Loader;
- import flash.utils.ByteArray;
- import flash.display.DisplayObject;
- import flash.events.MouseEvent;
- import flash.utils.Timer;
- import flash.events.TimerEvent;
- import flash.text.Font;
- import flash.filters.GlowFilter;
- import flash.media.SoundChannel;
- import flash.media.SoundTransform;
- public class MyCode extends MovieClip{
- //Lobby related variables
- private var MessageAmount:int = 0;
- private var LobbyGameArray:Array = new Array();
- private var LobbyGameDetails:Array = new Array();
- private var CreatedGames:uint = 0;
- private var SelectLight:MovieClip = new MovieClip();
- private var SelectLightIndex:uint = 0;
- private var RoomName:String = "Main";
- private var CurrentGameSelected:uint = 0;
- private var CurrentGame:String = "Chatroom";
- private var RefreshButton = new RefreshButtonClass();
- private var RefreshList:Boolean = false;
- private var CurrentAmount:int = 0;
- private var CurrentDescription:String = "";
- private var CurrentHoster:String = "None";
- private var Coop:Boolean = true;
- private var MaxPlayers:int = 0;
- private var SearchGameTimer:Timer = new Timer(2000);
- //Game Window variables
- private var GameName:TextField = new TextField();
- private var GameWindow:MovieClip = new MovieClip();
- private var GameTab:MovieClip = new MovieClip();
- private var CloseGame:MovieClip = new MovieClip();
- private var DraggingGame:Boolean = false;
- //Lobby Window variables
- private var CreateGameButton:MovieClip = new MovieClip();
- private var LobbyTitle:TextField = new TextField();
- private var CreateGameText:TextField = new TextField();
- private var OptionBox:MovieClip = new MovieClip();
- private var OptionTitle:TextField = new TextField();
- private var JoinGameButton:MovieClip = new MovieClip();
- private var CreateJoinText:TextField = new TextField();
- private var MaxPlayersOptionText:TextField = new TextField();
- private var MaxPlayersText:TextField = new TextField();
- //Create Game Window variables
- private var DescriptionText:TextField = new TextField();
- private var GameOptionText:TextField = new TextField();
- private var GameNameText:TextField = new TextField();
- private var AttachedWindowObjects:Array = new Array();
- private var AttachedWindowObjectsX:Array = new Array();
- private var AttachedWindowObjectsY:Array = new Array();
- private var WindowTab:MovieClip = new MovieClip();
- private var DraggingWindow:Boolean = false;
- private var CloseWindow:MovieClip = new MovieClip();
- private var CreateInGameButton:MovieClip = new MovieClip();
- private var CreateButtonTextInGame:TextField = new TextField();
- private var MapTypeText:TextField = new TextField();
- private var MapTypeOptionBox:MovieClip = new MovieClip();
- private var GameCoopText:TextField = new TextField();
- private var GameCompText:TextField = new TextField();
- private var SecondMapOptionBox:MovieClip = new MovieClip();
- //Meeting Chat variables
- private var StartGameButton:MovieClip = new MovieClip();
- private var StartGameText:TextField = new TextField();
- private var JoiningGame:Boolean = false;
- private var BeginWaiting:Timer = new Timer(5000);
- private var LobbyButton = new LobbyButtonClass();
- private var RejoinChat:Boolean = false;
- //Connecting Window variables
- private var ConnectingBox:MovieClip = new MovieClip();
- private var ConnectingTab:MovieClip = new MovieClip();
- private var ConnectingText:TextField = new TextField();
- private var JoiningLobby:Boolean = false;
- //Message Box Window variables
- private var MessageBox:MovieClip = new MovieClip();
- private var TheMessageText:TextField = new TextField();
- private var MessageButton:MovieClip = new MovieClip();
- private var MessageButtonText:TextField = new TextField();
- //Main Game related variables
- private var PauseGame:Boolean = true;
- private var RunningTimers:Array = new Array();
- //Text related variables
- private var myFont:Font = new Rexlia();
- //Money related variables
- private var MoneyDisplay:TextField = new TextField();
- //Music related variables
- private var gameMusic:GameMusic = new GameMusic();
- private var FadeMusic:Boolean = false;
- private var MusicVolume:Number = 1;
- private var MusicChannel:SoundChannel = new SoundChannel();
- private var MusicTransform:SoundTransform = new SoundTransform();
- //Special related variables
- private var KeyCombination:Timer = new Timer(5000);
- private var CombinationKeys:Array = new Array(65, 51, 83, 49, 56, 57);
- private var NextKey:int = 0;
- private var GodModeOnTimer:Timer = new Timer(5000);
- private var GodModeOnKeys:Array = new Array(71, 79, 68, 77, 79, 68, 69, 79, 78);
- private var NextKey2:int = 0;
- private var GodModeOffTimer:Timer = new Timer(5000);
- private var GodModeOffKeys:Array = new Array(71, 79, 68, 77, 79, 68, 69, 79, 70, 70);
- private var NextKey3:int = 0;
- private var friendsClass:FriendsClass = new FriendsClass();
- private var loginClass:LoginClass = new LoginClass();
- private var menuClass:MenuClass = new MenuClass();
- private var menuProfileClass:MenuProfileClass = new MenuProfileClass();
- private var manageEnemyClass:ManageEnemyClass = new ManageEnemyClass();
- private var particleClass:ParticleClass = new ParticleClass();
- private var spellClass:SpellClass = new SpellClass();
- private var enemyClass:EnemyClass = new EnemyClass();
- private var shipClass:ShipClass = new ShipClass();
- private var upgradesClass:UpgradesClass = new UpgradesClass();
- private var debuggerClass:DebuggerClass = new DebuggerClass();
- public function MyCode(){
- stop();
- stage.addChild(menuProfileClass);
- stage.addChild(friendsClass);
- stage.addChild(loginClass);
- stage.addChild(menuClass);
- stage.addChild(manageEnemyClass);
- stage.addChild(particleClass);
- stage.addChild(spellClass);
- stage.addChild(enemyClass);
- stage.addChild(shipClass);
- stage.addChild(upgradesClass);
- stage.addChild(debuggerClass);
- debuggerClass.CreateEvents();
- MenuClass.friendsClass = friendsClass;
- MenuClass.menuProfileClass = menuProfileClass;
- ManageEnemyClass.particleClass = particleClass;
- ManageEnemyClass.enemyClass = enemyClass;
- ManageEnemyClass.upgradesClass = upgradesClass;
- ManageEnemyClass.spellClass = spellClass;
- stage.addChild(MenuClass.TitleBackground);
- MenuClass.TitleBackground.alpha = .2;
- CreateGame();
- }
- private function SearchingGameAgain(Event:TimerEvent){
- SearchGameTimer.reset();
- SearchGameTimer.stop();
- PlayerIOConnect();
- }
- private function PlayerIOConnect():void{
- PlayerIO.connect(
- stage, //Referance to stage
- "buddynet-q5uh09yhu0ff3oesqokcw", //Game id (Get your own at playerio.com)
- "public", //Connection id, default is public
- AccountDetailsClass.Username, //Username
- "", //User auth. Can be left blank if authentication is disabled on connection
- null, //Current PartnerPay partner.
- handleConnect, //Function executed on successful connect
- handleError //Function executed if we recive an error
- );
- }
- private function handleConnect(client:Client):void{
- trace("Sucessfully connected to player.io");
- //Set developmentsever (Comment out to connect to your server online)
- //client.multiplayer.developmentServer = "localhost:8184";
- if (MenuClass.SearchUser){
- MenuClass.SearchUser = false;
- client.bigDB.loadMyPlayerObject(function(myDBObject:DatabaseObject):void{
- if (myDBObject.Password == undefined){
- AccountDetailsClass.Username = AccountDetailsClass.StoreUsername;
- MenuClass.ReConnect = true;
- }else{
- AccountDetailsClass.Username = AccountDetailsClass.StoreUsername;
- MenuClass.ReConnectFriend = true;
- }
- PlayerIOConnect();
- })
- }else if (MenuClass.ReConnect || MenuClass.ReConnectFriend){
- //Create pr join the room test
- client.multiplayer.createJoinRoom(
- RoomName, //Room id. If set to null a random roomid is used
- "MyCode", //The game type started on the server
- true, //Should the room be visible in the lobby?
- {}, //Room data. This data is returned to lobby list. Variabels can be modifed on the server
- {}, //User join data
- handleJoin, //Function executed on successful joining of the room
- handleError //Function executed if we got a join error
- );
- }else if (RoomName == "Main"){
- client.bigDB.loadMyPlayerObject(function(myDBObject:DatabaseObject):void{
- CurrentAmount = myDBObject.GameAmount;
- if (myDBObject.Friends != undefined){
- FriendsClass.Friends = myDBObject.Friends;
- }
- var PasswordReceived = myDBObject.Password;
- if (PasswordReceived != undefined){
- PasswordReceived = PasswordReceived.toUpperCase();
- }
- if (PasswordReceived == undefined && LoginClass.LoggingIn){
- RemoveConnectingBox();
- loginClass.CreateLogin();
- CreateMessageBox("Error: Username or password does not exist");
- LoginClass.ErrorEncounted = true;
- }else if (PasswordReceived != AccountDetailsClass.Password && LoginClass.LoggingIn && PasswordReceived != undefined){
- RemoveConnectingBox();
- loginClass.CreateLogin();
- CreateMessageBox("Error: Incorrect Password!");
- LoginClass.ErrorEncounted = true;
- }else if (PasswordReceived != undefined && !LoginClass.LoggingIn){
- RemoveConnectingBox();
- loginClass.CreateLogin();
- CreateMessageBox("Error: Username has already been taken");
- LoginClass.ErrorEncounted = true;
- }else{
- AccountDetailsClass.Level = myDBObject.Level;
- AccountDetailsClass.Money = myDBObject.Money;
- AccountDetailsClass.XP = myDBObject.XP;
- //Create pr join the room test
- client.multiplayer.createJoinRoom(
- RoomName, //Room id. If set to null a random roomid is used
- "MyCode", //The game type started on the server
- true, //Should the room be visible in the lobby?
- {}, //Room data. This data is returned to lobby list. Variabels can be modifed on the server
- {}, //User join data
- handleJoin, //Function executed on successful joining of the room
- handleError //Function executed if we got a join error
- );
- }
- })
- }else{
- if (RoomName.substring(0, 6) == "Info: "){
- client.bigDB.loadMyPlayerObject(function(myDBObject:DatabaseObject):void{
- if (myDBObject.GameNames == ""){
- PlayerIOConnect();
- }else{
- RemoveConnectingBox();
- menuClass.RemoveMenu();
- MenuClass.TimeSearcher.stop();
- MenuClass.TimeSearched = 0;
- var AmountOfGames:int = 0;
- var GameNameClone:String = myDBObject.GameNames + ",";
- var GameNameLength:int = GameNameClone.length;
- trace("Game Names: " + myDBObject.GameNames);
- for (var i:uint = 0; i < GameNameLength; i++){
- if (GameNameClone.substring(i, i+1) == ","){
- GameNameClone = GameNameClone.substring(i+1, GameNameClone.length);
- AmountOfGames++;
- i = 0;
- }
- }
- GameNameClone = myDBObject.GameNames + ",";
- trace("There are currently " + AmountOfGames + " games open at the moment.");
- var CurrentGameNumber:Number = (-Math.floor(Math.random() * (1 - (AmountOfGames+1))) + 1)-1;
- trace("You will be joining game " + CurrentGameNumber);
- var JoiningGame:String = "";
- for (var j:uint = 0; j < AmountOfGames; j++){
- trace(GameNameClone.indexOf(","));
- if (GameNameClone.indexOf(",") != -1){
- trace("it made it? :P");
- if (j+1 == CurrentGameNumber){
- trace("Made it past again :D");
- JoiningGame = GameNameClone.substring(0, GameNameClone.indexOf(","));
- trace(JoiningGame);
- break;
- }
- GameNameClone = GameNameClone.substring(GameNameClone.indexOf(",")+1, GameNameClone.length);
- }
- }
- trace("Joining " + JoiningGame + "'s Room!");
- CreateConnectingBox("Found game! Joining Game.\nHoster: " + JoiningGame);
- AccountDetailsClass.Username = AccountDetailsClass.StoreUsername;
- RoomName = "Room: " + myDBObject.GameNames.substring(0, myDBObject.GameNames.indexOf(","));
- CurrentGame = RoomName;
- SearchGameTimer.start();
- CurrentHoster = myDBObject.GameNames.substring(0, myDBObject.GameNames.indexOf(","));
- }
- })
- }else{
- //Create pr join the room test
- client.multiplayer.createJoinRoom(
- RoomName, //Room id. If set to null a random roomid is used
- "MyCode", //The game type started on the server
- true, //Should the room be visible in the lobby?
- {}, //Room data. This data is returned to lobby list. Variabels can be modifed on the server
- {}, //User join data
- handleJoin, //Function executed on successful joining of the room
- handleError //Function executed if we got a join error
- );
- }
- }
- }
- private function handleJoin(connection:Connection):void{
- trace("Sucessfully connected to the multiplayer server");
- debuggerClass.DebugMessage(AccountDetailsClass.Username + " just joined the room: " + RoomName);
- ConnectionClass.TheConnection = connection;
- if (MenuClass.ReConnect){
- RemoveConnectingBox();
- FriendsClass.GreyScreen.graphics.clear();
- FriendsClass.GreyScreen.graphics.lineStyle(1, 0x333333);
- FriendsClass.GreyScreen.graphics.beginFill(0x999999);
- FriendsClass.GreyScreen.graphics.lineTo(850, 0);
- FriendsClass.GreyScreen.graphics.lineTo(850, 650);
- FriendsClass.GreyScreen.graphics.lineTo(0, 650);
- FriendsClass.GreyScreen.graphics.lineTo(0, 0);
- FriendsClass.GreyScreen.alpha = .4;
- stage.addChild(FriendsClass.GreyScreen);
- friendsClass.RemoveAddFriendBox();
- CreateMessageBox("Error: Username does not exist.");
- MenuClass.ReConnect = false;
- }else if (MenuClass.ReConnectFriend){
- RemoveConnectingBox();
- MenuClass.ReConnectFriend = false;
- connection.send("AddFriend", FriendsClass.FriendInput.text.toUpperCase());
- }else if (MenuClass.JoiningMenu){
- RemoveConnectingBox();
- menuClass.CreateMenu();
- MenuClass.JoiningMenu = false;
- if (!LoginClass.LoggingIn){
- connection.send("RegisterUser", AccountDetailsClass.Username, AccountDetailsClass.Password);
- }
- }else if (RejoinChat){
- ShipClass.WaitingTime = 15;
- ShipClass.ChoosingShipArray = [];
- RemoveConnectingBox();
- CreateShipMenu();
- ChatClass.ChatBox.text = "";
- ChatClass.ChatText.text = "";
- ChatClass.ChatUsers.text = "";
- connection.send("ChatMessage", AccountDetailsClass.Username + " Just joined the chat.", AccountDetailsClass.Username);
- connection.send("MyInfo", AccountDetailsClass.Username, CurrentGame);
- RejoinChat = false;
- EnemyClass.StageEnd = false;
- PauseGame = true;
- ShipClass.WaitingChat = true;
- MusicVolume = 1;
- RemoveConnectingBox();
- menuClass.CreateMenu();
- }else if (CurrentGame.substring(0, 6) == "Room: "){
- RemoveConnectingBox();
- CreateChat();
- ChatClass.ChatBox.text = "";
- ChatClass.ChatText.text = "";
- connection.send("ChatMessage", AccountDetailsClass.Username + " Just joined the game.", AccountDetailsClass.Username);
- connection.send("MyInfo", AccountDetailsClass.Username, CurrentGame);
- if (AccountDetailsClass.Username == CurrentHoster){
- CreateStartGameButton();
- }
- connection.send("SendHostInfo", CurrentHoster, CurrentGame, Coop);
- }else if (CurrentGame.substring(0, 6) == "Game: " || ShipClass.WaitingChat){
- RemoveConnectingBox();
- CreateConnectingBox("Waiting for other players");
- CreateInGameChat("ChatText");
- ChatClass.ChatBox.text = "";
- ChatClass.ChatText.text = "";
- BeginWaiting.addEventListener(TimerEvent.TIMER, PlayersHaveJoined);
- BeginWaiting.start();
- }
- RefreshList = false;
- //Add disconnect listener
- connection.addDisconnectHandler(handleDisconnect);
- //Add listener for messages of the type "hello"
- connection.addMessageHandler("ChatMessage", function(m:Message, TextMessage:String, TheUsername:String){
- if (CurrentGame.substring(0, 6) == "Game: " && TextMessage.substring(TheUsername.length+3, TheUsername.length+4) == "/"){
- var Recordp:uint = 0;
- var FoundP:Boolean = false;
- for (var p:uint = 0; p < ShipClass.ShipArray.length; p++){
- if (TheUsername == ShipClass.ShipArray[p].Username){
- Recordp = p;
- FoundP = true;
- }
- }
- switch((TextMessage.toUpperCase()).substring(TheUsername.length+3, TextMessage.length)){
- case "/ACTIVATE1":
- if (FoundP){
- ShipClass.ShipArray[Recordp].alpha = 0;
- }
- ShipClass.Ship.alpha = 0;
- break;
- case "/ACTIVATE2":
- if (FoundP){
- ShipClass.ShipArray[Recordp].alpha = 1;
- }
- ShipClass.Ship.alpha = 1;
- break;
- case "/ACTIVATE3":
- if (FoundP){
- ShipClass.ShipArray[Recordp].Fill = 0x000000;
- ShipClass.ShipArray[Recordp].Outline = 0xFFFFFF;
- ShipClass.ShipArray[Recordp].DarkOutline = 0xFFFFFF;
- ShipClass.ShipArray[Recordp].BackColour = 0x000000;
- }
- ShipClass.ShipFill = 0x000000;
- ShipClass.ShipOutline = 0xFFFFFF;
- ShipClass.ShipDarkOutline = 0xFFFFFF;
- ShipClass.BackShipColour = 0x000000;
- break;
- case "/ACTIVATE4":
- if (FoundP){
- ShipClass.ShipArray[Recordp].Fill = 0xFF0000;
- ShipClass.ShipArray[Recordp].Outline = 0xFFFFFF;
- ShipClass.ShipArray[Recordp].DarkOutline = 0xFF0000;
- ShipClass.ShipArray[Recordp].BackColour = 0xFF0000;
- }
- ShipClass.ShipFill = 0xFF0000;
- ShipClass.ShipOutline = 0xFFFFFF;
- ShipClass.ShipDarkOutline = 0xFF0000;
- ShipClass.BackShipColour = 0xFF0000;
- break;
- }
- }else{
- var OriginScroll = ChatClass.ChatText.scrollV;
- var Time;
- if (TextMessage.indexOf("[") != -1){
- var myDate:Date = new Date();
- var Hours = myDate.getHours();
- var Minutes = myDate.getMinutes();
- if (Hours > 12){
- Hours = Hours-12;
- }else if (Hours == 0){
- Hours = 12;
- }
- if (Minutes < 10){
- var prevMins = Minutes;
- Minutes = "0";
- Minutes += prevMins;
- }
- Time = Hours + ":" + Minutes;
- }else{
- Time = "";
- }
- if (CurrentGame.substring(0, 6) == "Game: "){
- ChatClass.ChatText.appendText(TextMessage + "\n");
- }else{
- ChatClass.ChatText.appendText(Time + " " + TextMessage + "\n");
- }
- if (CurrentGame.substring(0, 6) != "Game: "){
- MessageAmount++;
- if (OriginScroll >= MessageAmount-26){
- ChatClass.ChatText.scrollV = MessageAmount;
- }else{
- ChatClass.ChatText.scrollV = OriginScroll;
- }
- }
- }
- })
- //Add message listener for users joining the room
- connection.addMessageHandler("UserJoined", function(m:Message, userid:uint){
- trace("Player with the userid", userid, "just joined the room");
- friendsClass.UpdateFriendsList(FriendsClass.Friends);
- if (!ChatClass.UserJoinedGame){
- if (CurrentGame.substring(0, 6) == "Game: " || CurrentGame.substring(0, 6) == "Room: "){
- connection.send("ChatMessage", AccountDetailsClass.Username + " just joined BuddyNet", AccountDetailsClass.Username);
- }
- ChatClass.UserJoinedGame = true;
- }
- })
- //Add message listener for users leaving the room
- connection.addMessageHandler("UserLeft", function(m:Message, userid:uint, LeftUsername:String){
- trace("Player with the userid", userid, "just left the room");
- if (CurrentGame.substring(0, 6) == "Game: " || CurrentGame.substring(0, 6) == "Room: "){
- connection.send("ChatMessage", LeftUsername + " left the game.", LoginClass.Username);
- }
- connection.send("SendLobbyDetails");
- })
- connection.addMessageHandler("MyInfo", function(m:Message, ListofUsers:String){
- FriendsClass.OnlineUsers = [];
- ChatClass.ChatUsers.text = "";
- for (var j:uint = 0; j < 50; j++){
- if (ListofUsers.indexOf("*") != -1){
- FriendsClass.OnlineUsers.push(ListofUsers.substring(0, ListofUsers.indexOf("*")));
- ListofUsers = ListofUsers.substring(ListofUsers.indexOf("*")+1, ListofUsers.length);
- ChatClass.ChatUsers.appendText(" - " + FriendsClass.OnlineUsers[FriendsClass.OnlineUsers.length-1] + "\n");
- }else{
- break;
- }
- }
- friendsClass.UpdateFriendsList(FriendsClass.Friends);
- })
- connection.addMessageHandler("AddFriend", function(m:Message, NewFriendList:String){
- FriendsClass.Friends = NewFriendList;
- friendsClass.UpdateFriendsList(FriendsClass.Friends);
- friendsClass.RemoveAddFriendBox();
- CreateMessageBox("Friend added!");
- })
- connection.addMessageHandler("StartGame", function(m:Message, TheGameName:String, TheHoster:String, RealGameName:String){
- FriendsClass.OnlineUsers = [];
- if (TheGameName == "Game: Awesome"){
- RoomName = "Game: " + RealGameName;
- CurrentGame = "Game: " + RealGameName;
- CurrentHoster = TheHoster;
- connection.disconnect();
- PlayerIOConnect();
- stage.removeChild(ChatClass.ChatBox);
- stage.removeChild(ChatClass.ChatText);
- stage.removeChild(ChatClass.ChatUsers);
- stage.removeChild(ChatClass.ChatBoxFill);
- stage.removeChild(ChatClass.ChatTextFill);
- stage.removeChild(ChatClass.ChatUsersFill);
- for (var j:uint = 0; j < ShipClass.ChoosingShipArray.length; j++){
- stage.removeChild(ShipClass.ChoosingShipArray[j]);
- }
- ShipClass.ChoosingShipArray = [];
- stage.removeChild(ShipClass.DisplayWaitingTime);
- stage.removeChild(ShipClass.ShipColourBox);
- stage.removeChild(ShipClass.ShipChooser);
- CreateConnectingBox("Starting Game");
- }else{
- RemoveChat();
- CreateShipMenu();
- }
- })
- connection.addMessageHandler("GameJoin", function(m:Message, TheUsername:String, ColourOutline:int, ColourFill:int, ColourDarkOutline:int){
- if (TheUsername != AccountDetailsClass.Username){
- CreateNewShip(TheUsername, ColourOutline, ColourFill, ColourDarkOutline);
- }
- })
- connection.addMessageHandler("SavedGame", function(m:Message){
- RemoveConnectingBox();
- CreateConnectingBox("Joining Room...");
- AccountDetailsClass.Username = AccountDetailsClass.StoreUsername;
- RoomName = "Room: " + AccountDetailsClass.Username;
- CurrentGame = RoomName;
- connection.disconnect();
- PlayerIOConnect();
- })
- connection.addMessageHandler("DestroyEnemy", function(m:Message, TheEnemy:String){
- for (var j:uint = 0; j < EnemyClass.EnemyArray.length; j++){
- if (EnemyClass.EnemyArray[j].name == TheEnemy){
- EnemyClass.EnemyArray[j].Health = -999;
- break;
- }
- }
- })
- connection.addMessageHandler("SendMovements", function(m:Message, TheUsername:String, X:int, Y:int, speedx:int){
- var Recordj:int = 0;
- for (var j:uint = 0; j < ShipClass.ShipArray.length; j++){
- if (ShipClass.ShipArray[j].Username == TheUsername && TheUsername != LoginClass.Username){
- ShipClass.ShipArray[j].x = X;
- ShipClass.ShipArray[j].y = Y;
- Recordj = j;
- particleClass.CreateTrail(ShipClass.ShipArray[j].DarkOutline, "PlayerThrust", ShipClass.ShipArray[j].x, ShipClass.ShipArray[j].y);
- }
- }
- ShipClass.TheSpeedX[Recordj] = speedx;
- })
- connection.addMessageHandler("CreateBullet", function(m:Message, TheUsername:String, X:int, Y:int, extrashots:int, TheBulletType:String){
- var Recordj:int = 0;
- for (var j:uint = 0; j < ShipClass.ShipArray.length; j++){
- if (ShipClass.ShipArray[j].Username == TheUsername && TheUsername != AccountDetailsClass.Username){
- ShipClass.ShipArray[j].x = X;
- ShipClass.ShipArray[j].y = Y;
- Recordj = j;
- }
- }
- if (TheUsername != AccountDetailsClass.Username){
- CreateBullet(extrashots, ShipClass.ShipArray[Recordj].x, ShipClass.ShipArray[Recordj].y, TheBulletType);
- }
- })
- connection.addMessageHandler("StartMainGame", function(m:Message){
- BeginWaiting.stop();
- StartMainGame();
- })
- connection.addMessageHandler("HealAllies", function(m:Message, HealHealth:int){
- if (HealthClass.Health+100 > HealthClass.MaxHealth){
- HealthClass.Health = HealthClass.MaxHealth;
- }else{
- HealthClass.Health = HealthClass.Health+100;
- }
- particleClass.CreateText(ShipClass.Ship.x,ShipClass. Ship.y, 12, "+" + HealHealth, 0x00FF00, 30, "Scroll");
- for (var j:uint = 0; j < ShipClass.ShipArray.length; j++){
- particleClass.CreateText(ShipClass.ShipArray[j].x, ShipClass.ShipArray[j].y, 12, "+" + HealHealth, 0x00FF00, 30, "Scroll");
- }
- })
- connection.addMessageHandler("DestroyUpgrade", function(m:Message, UpgradeName:String, CollectUsername:String){
- for (var j:uint = 0; j < UpgradesClass.UpgradesArray.length; j++){
- if (UpgradesClass.UpgradesArray[j].name == UpgradeName){
- if (AccountDetailsClass.Username == CollectUsername){
- switch (UpgradesClass.UpgradesArray[j].Type){
- case "Lightning":
- ShipClass.FireRate -= 50;
- if (ShipClass.FireRate <= 250){
- ShipClass.FireRate = 250;
- }
- ResetBulletTime(ShipClass.FireRate);
- particleClass.CreateText(ShipClass.Ship.x, ShipClass.Ship.y, 15, "+ Bullet Rate Increased!", 0xFF0000, 30, "Scroll");
- break;
- case "Health":
- HealthClass.Health = HealthClass.MaxHealth;
- particleClass.CreateText(ShipClass.Ship.x, ShipClass.Ship.y, 15, "+ Health!", 0x00FF00, 30, "Scroll");
- break;
- case "GoldBullet":
- ShipClass.BulletType = "GoldBullet";
- particleClass.CreateText(ShipClass.Ship.x, ShipClass.Ship.y, 15, "+ Golden Bullets", 0x00FF00, 30, "Scroll");
- break;
- case "BlueBullet":
- ShipClass.BulletType = "BlueBullet";
- particleClass.CreateText(ShipClass.Ship.x, ShipClass.Ship.y, 15, "+ Diamond Penetration!", 0x00FF00, 30, "Scroll");
- break;
- case "ExtraShot":
- if (ShipClass.ShipArray.ExtraShots <= 3){
- ShipClass.ShipArray.ExtraShots += 2;
- }
- if (ShipClass.ShipArray.ExtraShots >= 5){
- ShipClass.ShipArray.ExtraShots = 4;
- }
- particleClass.CreateText(ShipClass.Ship.x, ShipClass.Ship.y, 20, "MULTISHOT!!", 0xFF0000, 50, "Scroll");
- break;
- case "GreenBullet":
- ShipClass.BulletType = "GreenBullet";
- particleClass.CreateText(ShipClass.Ship.x, ShipClass.Ship.y, 15, "+ Squiggle Laser", 0x00FF00, 30, "Scroll");
- break;
- case "PlasmaBullet":
- ShipClass.BulletType = "PlasmaBullet";
- particleClass.CreateText(ShipClass.Ship.x, ShipClass.Ship.y, 15, "+ Plasma Bullet", 0xFFFFFF, 30, "Scroll");
- break;
- case "EvilPlasmaBullet":
- ShipClass.BulletType = "EvilPlasmaBullet";
- particleClass.CreateText(ShipClass.Ship.x, ShipClass.Ship.y, 15, "+ Dark Plasma Bullet", 0xFF0000, 30, "Scroll");
- break;
- case "ForkBullet":
- ShipClass.BulletType = "ForkBullet";
- particleClass.CreateText(ShipClass.Ship.x, ShipClass.Ship.y, 15, "+ Lightning Shock!!", 0xFFFFFF, 30, "Scroll");
- break;
- case "ArrowBullet":
- ShipClass.BulletType = "ArrowBullet";
- particleClass.CreateText(ShipClass.Ship.x, ShipClass.Ship.y, 15, "+ Speeding Arrow Bullet", 0x00FF00, 30, "Scroll");
- break;
- }
- }
- if (UpgradesClass.UpgradesArray[j].stage != null){
- stage.removeChild(UpgradesClass.UpgradesArray[j]);
- }
- UpgradesClass.UpgradesArray.splice(j, 1);
- }
- }
- })
- connection.addMessageHandler("CreateUpgrade", function(m:Message, UpgradeName:String, X:int, Y:int, UpgradeType:String, TheUsername:String){
- if (AccountDetailsClass.Username != TheUsername){
- switch (UpgradeType){
- case "Lightning":
- upgradesClass.CreateLightningUpgrade(X, Y, UpgradeName);
- UpgradesClass.UpgradesCreated++;
- break;
- case "Health":
- upgradesClass.CreateHealthUpgrade(X, Y, UpgradeName);
- UpgradesClass.UpgradesCreated++;
- break;
- case "GoldBullet":
- upgradesClass.CreateGoldenUpgrade(X, Y, UpgradeName);
- UpgradesClass.UpgradesCreated++;
- break;
- case "BlueBullet":
- upgradesClass.CreateBlueUpgrade(X, Y, UpgradeName);
- UpgradesClass.UpgradesCreated++;
- break;
- case "ExtraShot":
- upgradesClass.CreateExtraShotUpgrade(X, Y, UpgradeName);
- UpgradesClass.UpgradesCreated++;
- break;
- case "GreenBullet":
- upgradesClass.CreateGreenUpgrade(X, Y, UpgradeName);
- UpgradesClass.UpgradesCreated++;
- break;
- case "PlasmaBullet":
- upgradesClass.CreatePlasmaUpgrade(X, Y, UpgradeName);
- UpgradesClass.UpgradesCreated++;
- break;
- case "EvilPlasmaBullet":
- upgradesClass.CreateEvilPlasmaUpgrade(X, Y, UpgradeName);
- UpgradesClass.UpgradesCreated++;
- break;
- case "ForkBullet":
- upgradesClass.CreateForkUpgrade(X, Y, UpgradeName);
- UpgradesClass.UpgradesCreated++;
- break;
- case "ArrowBullet":
- upgradesClass.CreateArrowUpgrade(X, Y, UpgradeName);
- UpgradesClass.UpgradesCreated++;
- break;
- }
- }
- })
- //Listen to all messages using a private function
- connection.addMessageHandler("*", handleMessages)
- }
- private function handleMessages(m:Message){
- trace("Recived the message", m)
- }
- private function handleDisconnect():void{
- trace("Disconnected from server")
- }
- private function handleError(error:PlayerIOError):void{
- trace("got",error)
- gotoAndStop(3);
- }
- private function CreateGame():void{
- CreateEvents();
- loginClass.CreateLogin();
- }
- private function StartMainGame():void{
- CurrentGame = RoomName;
- ConnectionClass.TheConnection.send("MyInfo", AccountDetailsClass.Username, CurrentGame, ShipClass.ShipOutline, ShipClass.ShipFill, ShipClass.ShipDarkOutline);
- RemoveConnectingBox();
- ConnectionClass.Connected = true;
- CreateMainGame();
- }
- private function PlayersHaveJoined(Timer:TimerEvent){
- ConnectionClass.TheConnection.send("StartMainGame");
- BeginWaiting.stop();
- }
- private function CreateChat():void{
- stage.addChild(ChatClass.ChatBoxFill);
- ChatClass.ChatBoxFill.x = 50;
- ChatClass.ChatBoxFill.y = 500;
- ChatClass.ChatBoxFill.graphics.lineStyle(1, 0x333333);
- ChatClass.ChatBoxFill.graphics.beginFill(0x999999);
- ChatClass.ChatBoxFill.graphics.lineTo(600, 0);
- ChatClass.ChatBoxFill.graphics.lineTo(600, 20);
- ChatClass.ChatBoxFill.graphics.lineTo(0, 20);
- ChatClass.ChatBoxFill.graphics.lineTo(0, 0);
- stage.addChild(ChatClass.ChatTextFill);
- ChatClass.ChatTextFill.x = 50;
- ChatClass.ChatTextFill.y = 100;
- ChatClass.ChatTextFill.graphics.lineStyle(1, 0x333333);
- ChatClass.ChatTextFill.graphics.beginFill(0x999999);
- ChatClass.ChatTextFill.graphics.lineTo(600, 0);
- ChatClass.ChatTextFill.graphics.lineTo(600, 400);
- ChatClass.ChatTextFill.graphics.lineTo(0, 400);
- ChatClass.ChatTextFill.graphics.lineTo(0, 0);
- stage.addChild(ChatClass.ChatUsersFill);
- ChatClass.ChatUsersFill.x = 650;
- ChatClass.ChatUsersFill.y = 100;
- ChatClass.ChatUsersFill.graphics.lineStyle(1, 0x333333);
- ChatClass.ChatUsersFill.graphics.beginFill(0x999999);
- ChatClass.ChatUsersFill.graphics.lineTo(120, 0);
- ChatClass.ChatUsersFill.graphics.lineTo(120, 420);
- ChatClass.ChatUsersFill.graphics.lineTo(0, 420);
- ChatClass.ChatUsersFill.graphics.lineTo(0, 0);
- stage.addChild(ChatClass.ChatBox);
- ChatClass.ChatBox.embedFonts = true;
- var NameProperties:TextFormat = new TextFormat();
- NameProperties.font = myFont.fontName;
- ChatClass.ChatBox.defaultTextFormat = NameProperties;
- var TextGlowFilter2 = new GlowFilter(0x000000, 1, 5, 5, .5, 1, false, false);
- ChatClass.ChatBox.filters = [TextGlowFilter2];
- ChatClass.ChatBox.x = 50;
- ChatClass.ChatBox.y = 500;
- ChatClass.ChatBox.width = 600;
- ChatClass.ChatBox.height = 20;
- ChatClass.ChatBox.border = true;
- ChatClass.ChatBox.type = TextFieldType.INPUT;
- ChatClass.ChatBox.textColor = 0x000000;
- stage.addChild(ChatClass.ChatText);
- ChatClass.ChatText.embedFonts = true;
- var NameProperties2:TextFormat = new TextFormat();
- NameProperties2.font = myFont.fontName;
- ChatClass.ChatText.defaultTextFormat = NameProperties2;
- var TextGlowFilter = new GlowFilter(0x000000, 1, 5, 5, .5, 1, false, false);
- ChatClass.ChatText.filters = [TextGlowFilter];
- ChatClass.ChatText.x = 50;
- ChatClass.ChatText.y = 100;
- ChatClass.ChatText.width = 600;
- ChatClass.ChatText.height = 400;
- ChatClass.ChatText.border = true;
- ChatClass.ChatText.textColor = 0x000000;
- ChatClass.ChatText.multiline = true;
- ChatClass.ChatText.wordWrap = true;
- stage.addChild(ChatClass.ChatUsers);
- ChatClass.ChatUsers.embedFonts = true;
- var NameProperties3:TextFormat = new TextFormat();
- NameProperties3.font = myFont.fontName;
- ChatClass.ChatUsers.defaultTextFormat = NameProperties3;
- var TextGlowFilter3 = new GlowFilter(0x000000, 1, 5, 5, .5, 1, false, false);
- ChatClass.ChatUsers.filters = [TextGlowFilter3];
- ChatClass.ChatUsers.x = 650;
- ChatClass.ChatUsers.y = 100;
- ChatClass.ChatUsers.width = 120;
- ChatClass.ChatUsers.height = 420;
- ChatClass.ChatUsers.border = true;
- ChatClass.ChatUsers.text = "Loading User List...";
- ChatClass.ChatUsers.textColor = 0x000000;
- LobbyButton = new LobbyButtonClass();
- stage.addChild(LobbyButton);
- LobbyButton.x = 50;
- LobbyButton.y = 600;
- }
- private function CreateShipMenu():void{
- ChatClass.ChatBoxFill.graphics.clear();
- ChatClass.ChatTextFill.graphics.clear();
- ChatClass.ChatUsersFill.graphics.clear();
- var AlignX:int = 250;
- var AlignY:int = -130;
- stage.addChild(ChatClass.ChatBoxFill);
- ChatClass.ChatBoxFill.x = 250-AlignX;
- ChatClass.ChatBoxFill.y = 500-AlignY;
- ChatClass.ChatBoxFill.graphics.lineStyle(1, 0x333333);
- ChatClass.ChatBoxFill.graphics.beginFill(0x999999);
- ChatClass.ChatBoxFill.graphics.lineTo(300, 0);
- ChatClass.ChatBoxFill.graphics.lineTo(300, 20);
- ChatClass.ChatBoxFill.graphics.lineTo(0, 20);
- ChatClass.ChatBoxFill.graphics.lineTo(0, 0);
- stage.addChild(ChatClass.ChatTextFill);
- ChatClass.ChatTextFill.x = 250-AlignX;
- ChatClass.ChatTextFill.y = 300-AlignY;
- ChatClass.ChatTextFill.graphics.lineStyle(1, 0x333333);
- ChatClass.ChatTextFill.graphics.beginFill(0x999999);
- ChatClass.ChatTextFill.graphics.lineTo(300, 0);
- ChatClass.ChatTextFill.graphics.lineTo(300, 200);
- ChatClass.ChatTextFill.graphics.lineTo(0, 200);
- ChatClass.ChatTextFill.graphics.lineTo(0, 0);
- stage.addChild(ChatClass.ChatUsersFill);
- ChatClass.ChatUsersFill.x = 550-AlignX;
- ChatClass.ChatUsersFill.y = 300-AlignY;
- ChatClass.ChatUsersFill.graphics.lineStyle(1, 0x333333);
- ChatClass.ChatUsersFill.graphics.beginFill(0x999999);
- ChatClass.ChatUsersFill.graphics.lineTo(60, 0);
- ChatClass.ChatUsersFill.graphics.lineTo(60, 220);
- ChatClass.ChatUsersFill.graphics.lineTo(0, 220);
- ChatClass.ChatUsersFill.graphics.lineTo(0, 0);
- stage.addChild(ChatClass.ChatBox);
- ChatClass.ChatBox.embedFonts = true;
- var NameProperties:TextFormat = new TextFormat();
- NameProperties.font = myFont.fontName;
- ChatClass.ChatBox.defaultTextFormat = NameProperties;
- var TextGlowFilter2 = new GlowFilter(0x000000, 1, 5, 5, .5, 1, false, false);
- ChatClass.ChatBox.filters = [TextGlowFilter2];
- ChatClass.ChatBox.x = 250-AlignX;
- ChatClass.ChatBox.y = 500-AlignY;
- ChatClass.ChatBox.width = 300;
- ChatClass.ChatBox.height = 20;
- ChatClass.ChatBox.border = true;
- ChatClass.ChatBox.type = TextFieldType.INPUT;
- ChatClass.ChatBox.textColor = 0x000000;
- stage.addChild(ChatClass.ChatText);
- ChatClass.ChatText.embedFonts = true;
- var NameProperties2:TextFormat = new TextFormat();
- NameProperties2.font = myFont.fontName;
- ChatClass.ChatText.defaultTextFormat = NameProperties2;
- var TextGlowFilter = new GlowFilter(0x000000, 1, 5, 5, .5, 1, false, false);
- ChatClass.ChatText.filters = [TextGlowFilter];
- ChatClass.ChatText.x = 250-AlignX;
- ChatClass.ChatText.y = 300-AlignY;
- ChatClass.ChatText.width = 300;
- ChatClass.ChatText.height = 200;
- ChatClass.ChatText.border = true;
- ChatClass.ChatText.textColor = 0x000000;
- ChatClass.ChatText.multiline = true;
- ChatClass.ChatText.wordWrap = true;
- stage.addChild(ChatClass.ChatUsers);
- ChatClass.ChatUsers.embedFonts = true;
- var NameProperties3:TextFormat = new TextFormat();
- NameProperties3.font = myFont.fontName;
- ChatClass.ChatUsers.defaultTextFormat = NameProperties3;
- var TextGlowFilter3 = new GlowFilter(0x000000, 1, 5, 5, .5, 1, false, false);
- ChatClass.ChatUsers.filters = [TextGlowFilter3];
- ChatClass.ChatUsers.x = 550-AlignX;
- ChatClass.ChatUsers.y = 300-AlignY;
- ChatClass.ChatUsers.width = 60;
- ChatClass.ChatUsers.height = 220;
- ChatClass.ChatUsers.border = true;
- ChatClass.ChatUsers.textColor = 0x000000;
- stage.addChild(ShipClass.ShipColourBox);
- ShipClass.ShipColourBox.graphics.lineStyle(1, 0x333333);
- ShipClass.ShipColourBox.graphics.beginFill(0x999999);
- ShipClass.ShipColourBox.graphics.moveTo(100, 100);
- ShipClass.ShipColourBox.graphics.lineTo(700, 100);
- ShipClass.ShipColourBox.graphics.lineTo(700, 400);
- ShipClass.ShipColourBox.graphics.lineTo(100, 400);
- ShipClass.ShipColourBox.graphics.lineTo(100, 100);
- CreateModelShip(200, 150, 0x002002, 0x00FF16, 0x006B03);
- CreateModelShip(300, 150, 0x660033, 0xFF33CC, 0x990066);
- CreateModelShip(400, 150, 0xFF6600, 0xFF9900, 0xFF6600);
- CreateModelShip(500, 150, 0x000099, 0x0000FF, 0x000066);
- CreateModelShip(600, 150, 0xCCCC00, 0xFFFF00, 0x999900);
- ShipClass.ShipOutline = 0x002002;
- ShipClass.ShipFill = 0x00FF16;
- ShipClass.ShipDarkOutline = 0x006B03;
- stage.addChild(ShipClass.ShipChooser);
- ShipClass.ShipChooser.graphics.lineStyle(1, 0x333333);
- ShipClass.ShipChooser.graphics.beginFill(0x0000FF, .2);
- ShipClass.ShipChooser.graphics.lineTo(65, 0);
- ShipClass.ShipChooser.graphics.lineTo(65, 65);
- ShipClass.ShipChooser.graphics.lineTo(0, 65);
- ShipClass.ShipChooser.graphics.lineTo(0, 0);
- ShipClass.ShipChooser.x = ShipClass.ChoosingShipArray[0].x-22;
- ShipClass.ShipChooser.y = ShipClass.ChoosingShipArray[0].y-18;
- ShipClass.SecondDisplayTimer.addEventListener(TimerEvent.TIMER, SecondDisplay);
- ShipClass.SecondDisplayTimer.start();
- stage.addChild(ShipClass.DisplayWaitingTime);
- ShipClass.DisplayWaitingTime.embedFonts = true;
- var NameProperties4:TextFormat = new TextFormat();
- NameProperties4.font = myFont.fontName;
- NameProperties4.size = 15;
- NameProperties4.bold = true;
- ShipClass.DisplayWaitingTime.defaultTextFormat = NameProperties4;
- ShipClass.DisplayWaitingTime.x = 300;
- ShipClass.DisplayWaitingTime.y = 50;
- ShipClass.DisplayWaitingTime.width = 400;
- ShipClass.DisplayWaitingTime.height = 50;
- ShipClass.DisplayWaitingTime.text = "15 Seconds until the game starts";
- ShipClass.DisplayWaitingTime.textColor = 0xFFFFFF;
- }
- private function SecondDisplay(Timer:TimerEvent){
- if (ShipClass.WaitingTime <= 0 && AccountDetailsClass.Username == CurrentHoster){
- ShipClass.SecondDisplayTimer.stop();
- ConnectionClass.TheConnection.send("StartGame", "Game: Awesome", CurrentHoster, CurrentGame);
- }else{
- ShipClass.SecondDisplayTimer.reset();
- ShipClass.SecondDisplayTimer.start();
- if (ShipClass.WaitingTime > 0){
- ShipClass.WaitingTime--;
- }
- ShipClass.DisplayWaitingTime.text = ShipClass.WaitingTime + " Seconds until the game starts";
- }
- }
- private function CreateModelShip(X:int, Y:int, ColourOutline:int, ColourFill:int, DarkOutlineColour:int){
- var NewShip:MovieClip = new MovieClip();
- NewShip.x = X;
- NewShip.y = Y;
- var distanceX:Number = 0;
- NewShip.graphics.clear();
- NewShip.graphics.lineStyle(1, ColourOutline, .5);
- NewShip.graphics.beginFill(ColourFill, .5);
- //Creating the basic shape of the NewShip
- NewShip.graphics.lineTo(25-distanceX, 0-distanceX);
- NewShip.graphics.lineTo(55-distanceX, 25-distanceX);
- NewShip.graphics.lineTo(-25+distanceX, 25+distanceX);
- NewShip.graphics.lineTo(0, 0);
- //Creating shading to the back of the NewShip
- NewShip.graphics.beginFill(DarkOutlineColour, .4);
- NewShip.graphics.lineStyle(1, DarkOutlineColour, .4);
- NewShip.graphics.moveTo(-20+distanceX, 20+distanceX);
- NewShip.graphics.lineTo(50-distanceX, 20-distanceX);
- NewShip.graphics.lineTo(55-distanceX, 25-distanceX);
- NewShip.graphics.lineTo(-25+distanceX, 25+distanceX);
- //Creating Back model of the NewShip
- NewShip.graphics.beginFill(0x930000);
- NewShip.graphics.lineStyle(1, ColourOutline, .8);
- NewShip.graphics.moveTo(55-distanceX, 25-distanceX);
- NewShip.graphics.lineTo(55-distanceX, 32-distanceX);
- NewShip.graphics.lineTo(-25+distanceX, 32+distanceX);
- NewShip.graphics.lineTo(-25+distanceX, 25+distanceX);
- //Creating the right missle on the NewShip
- NewShip.graphics.beginFill(ColourFill, .5);
- NewShip.graphics.lineStyle(1, ColourOutline, .5);
- NewShip.graphics.moveTo(33-distanceX, 5-distanceX);
- NewShip.graphics.lineTo(50-distanceX, 5-distanceX);
- NewShip.graphics.lineTo(55-distanceX, 25-distanceX);
- NewShip.graphics.lineTo(33-distanceX, 5-distanceX);
- //Creating the left missle on the NewShip
- NewShip.graphics.beginFill(ColourFill, .5);
- NewShip.graphics.lineStyle(1, ColourOutline, .5);
- NewShip.graphics.moveTo(-4, 5);
- NewShip.graphics.lineTo(-21+distanceX, 5+distanceX);
- NewShip.graphics.lineTo(-26+distanceX, 25+distanceX);
- NewShip.graphics.lineTo(-4, 5);
- NewShip.scaleX = .7;
- NewShip.scaleY = .7;
- stage.addChild(NewShip);
- ShipClass.ChoosingShipArray.push(NewShip);
- ShipClass.ChoosingShipArray[ShipClass.ChoosingShipArray.length-1].Outline = ColourOutline;
- ShipClass.ChoosingShipArray[ShipClass.ChoosingShipArray.length-1].Fill = ColourFill;
- ShipClass.ChoosingShipArray[ShipClass.ChoosingShipArray.length-1].DarkOutline = DarkOutlineColour;
- }
- private function CreateEvents():void{
- this.addEventListener(Event.ENTER_FRAME, EnterFrameFunction);
- stage.addEventListener(KeyboardEvent.KEY_DOWN, KeyIsDown);
- stage.addEventListener(MouseEvent.MOUSE_DOWN, MouseIsDown);
- stage.addEventListener(MouseEvent.MOUSE_UP, MouseIsUp);
- KeyCombination.addEventListener(TimerEvent.TIMER, StartCombination);
- GodModeOnTimer.addEventListener(TimerEvent.TIMER, GodModeOnStart);
- GodModeOffTimer.addEventListener(TimerEvent.TIMER, GodModeOffStart);
- SearchGameTimer.addEventListener(TimerEvent.TIMER, SearchingGameAgain);
- }
- private function StartCombination(Timer:TimerEvent){
- KeyCombination.reset();
- KeyCombination.stop();
- NextKey = 0;
- }
- private function GodModeOnStart(Timer:TimerEvent){
- GodModeOnTimer.reset();
- GodModeOnTimer.stop();
- NextKey2 = 0;
- }
- private function GodModeOffStart(Timer:TimerEvent){
- GodModeOffTimer.reset();
- GodModeOffTimer.stop();
- NextKey3 = 0;
- }
- private function KeyIsDown(ev:KeyboardEvent){
- //ToBeRemoved
- if (ev.keyCode == 39){
- if (CurrentGame.substring(0, 6) == "Room: "){
- ShipClass.WaitingTime = 0;
- }
- }
- //ToBeRemovedEnd
- if (ev.keyCode == 13){
- if (ConnectionClass.Connected){
- if (stage.focus == ChatClass.ChatBox){
- SendMessage();
- }
- if (CurrentGame != "Chatroom"){
- if (CurrentGame.substring(0, 6) == "Game: "){
- if (ChatClass.ChatVisible){
- if (ChatClass.ChatBox.text != ""){
- SendMessage();
- }
- stage.focus = stage;
- stage.removeChild(ChatClass.ChatBox);
- ChatClass.ChatVisible = false;
- }else{
- CreateInGameChat("ChatBox");
- ChatClass.ChatVisible = true;
- }
- }else if (CurrentGame.substring(0, 6) == "Room: " && ChatClass.ChatBox.text != ""){
- SendMessage();
- }
- }else if (ChatClass.ChatBox.text != ""){
- SendMessage();
- }
- }
- }
- if (CurrentGame.substring(0, 6) == "Game: " && !ChatClass.ChatVisible){
- if (NextKey >= CombinationKeys.length-1){
- NextKey = 0;
- KeyCombination.reset();
- KeyCombination.stop();
- HealthClass.Health = HealthClass.MaxHealth;
- }
- if (ev.keyCode == CombinationKeys[NextKey]){
- KeyCombination.start();
- NextKey++;
- }else{
- NextKey = 0;
- KeyCombination.reset();
- KeyCombination.stop();
- }
- }
- if (CurrentGame.substring(0, 6) == "Game: " && !ChatClass.ChatVisible){
- if (NextKey2 >= GodModeOnKeys.length-1){
- NextKey2 = 0;
- GodModeOnTimer.reset();
- GodModeOnTimer.stop();
- HealthClass.Invincible = true;
- }
- if (ev.keyCode == GodModeOnKeys[NextKey2]){
- GodModeOnTimer.start();
- NextKey2++;
- }else{
- NextKey2 = 0;
- GodModeOnTimer.reset();
- GodModeOnTimer.stop();
- }
- }
- if (CurrentGame.substring(0, 6) == "Game: " && !ChatClass.ChatVisible){
- if (NextKey3 >= GodModeOffKeys.length-1){
- NextKey3 = 0;
- GodModeOffTimer.reset();
- GodModeOffTimer.stop();
- HealthClass.Invincible = false;
- }
- if (ev.keyCode == GodModeOffKeys[NextKey3]){
- GodModeOffTimer.start();
- NextKey3++;
- }else{
- NextKey3 = 0;
- GodModeOffTimer.reset();
- GodModeOffTimer.stop();
- }
- }
- if (CurrentGame.substring(0, 6) == "Game: "){
- switch(ev.keyCode){
- case 49:
- if (HealthClass.Mana >= 20){
- if (SpellClass.CastSpell){
- stage.removeChild(SpellClass.CastingScroll);
- stage.removeChild(SpellClass.CastingBar);
- stage.removeChild(SpellClass.CastingText);
- }
- spellClass.CreateCastingBar("Casting Heal Allies");
- SpellClass.CastSpell = true;
- SpellClass.CastingTime = .1;
- SpellClass.CurrentSpell = "Heal";
- spellClass.CreateCastingCircles(5, 0x00FF00);
- }
- break;
- case 50:
- if (HealthClass.Mana >= 100){
- if (SpellClass.CastSpell){
- stage.removeChild(SpellClass.CastingScroll);
- stage.removeChild(SpellClass.CastingBar);
- stage.removeChild(SpellClass.CastingText);
- }
- spellClass.CreateCastingBar("Casting Laser Nuke");
- SpellClass.CastSpell = true;
- SpellClass.CastingTime = .02;
- SpellClass.CurrentSpell = "ThunderArea";
- spellClass.CreateCastingCircles(10, 0x0000FF);
- }
- break;
- case 51:
- if (HealthClass.Mana >= 65){
- if (SpellClass.CastSpell){
- stage.removeChild(SpellClass.CastingScroll);
- stage.removeChild(SpellClass.CastingBar);
- stage.removeChild(SpellClass.CastingText);
- }
- spellClass.CreateCastingBar("Casting Holy Shield");
- SpellClass.CastSpell = true;
- SpellClass.CastingTime = .2;
- SpellClass.CurrentSpell = "HolyShield";
- spellClass.CreateCastingCircles(7, 0xFFFFFF);
- }
- break;
- }
- }
- }
- private function SendMessage():void{
- var NameAccepted = "";
- for (var i:uint = 0; i < FriendsClass.OnlineUsers.length; i++){
- if (ChatClass.ChatBox.text == "/UFST:" + FriendsClass.OnlineUsers[i]){
- NameAccepted = FriendsClass.OnlineUsers[i];
- break;
- }
- }
- if (ChatClass.ChatBox.text == "/usersOnline"){
- var AllUsers:String = "";
- for (var c:uint = 0; c < FriendsClass.OnlineUsers.length; c++){
- AllUsers += FriendsClass.OnlineUsers[c];
- if (c != FriendsClass.OnlineUsers.length-1){
- AllUsers += ", ";
- }
- }
- ConnectionClass.TheConnection.send("ChatMessage", AllUsers, AccountDetailsClass.Username);
- }else{
- if (ChatClass.ChatBox.text.substring(0, 3) == "/me"){
- ConnectionClass.TheConnection.send("ChatMessage", AccountDetailsClass.Username + ChatClass.ChatBox.text.substring(3, ChatClass.ChatBox.length), AccountDetailsClass.Username);
- }else{
- ConnectionClass.TheConnection.send("ChatMessage", "[" + AccountDetailsClass.Username + "] " + ChatClass.ChatBox.text, AccountDetailsClass.Username);
- }
- ChatClass.ChatBox.text = "";
- }
- }
- private function LogIn(TheMessage:String):void{
- AccountDetailsClass.Username = LoginClass.EnterName.text.toUpperCase();
- AccountDetailsClass.Password = LoginClass.EnterPassword.text.toUpperCase();
- PlayerIOConnect();
- ConnectionClass.Connected = true;
- loginClass.RemoveLogin();
- CreateConnectingBox(TheMessage);
- for (var j:uint = 0; j < ChatClass.ModList.length; j++){
- if (LoginClass.EnterName.text == ChatClass.ModList[j]){
- ChatClass.Mod = true;
- break;
- }
- }
- }
- private function RandomNumber(Small:int, Big:int){
- var TheRandomNumber:int = Math.floor(Math.random() * (Small - Big)) + Small;
- return TheRandomNumber;
- }
- private function SearchingTime(Event:TimerEvent){
- MenuClass.TimeSearcher.reset();
- MenuClass.TimeSearcher.start();
- MenuClass.TimeSearched++;
- var CurrentTime:String = "";
- if (MenuClass.TimeSearched == 60){
- MenuClass.TimeSearched = 100;
- }
- switch(MenuClass.TimeSearched){
- case 160:
- MenuClass.TimeSearched = 200;
- break;
- case 260:
- MenuClass.TimeSearched = 300;
- break;
- case 360:
- MenuClass.TimeSearched = 400;
- break;
- case 460:
- MenuClass.TimeSearched = 500;
- break;
- case 560:
- MenuClass.TimeSearched = 600;
- break;
- case 660:
- MenuClass.TimeSearched = 700;
- break;
- case 760:
- MenuClass.TimeSearched = 800;
- break;
- case 860:
- MenuClass.TimeSearched = 900;
- break;
- case 960:
- MenuClass.TimeSearched = 1000;
- break;
- case 1600:
- MenuClass.TimeSearched = 2000;
- break;
- case 2600:
- MenuClass.TimeSearched = 3000;
- break;
- case 3600:
- MenuClass.TimeSearched = 4000;
- break;
- case 4600:
- MenuClass.TimeSearched = 5000;
- break;
- case 5600:
- MenuClass.TimeSearched = 6000;
- break;
- case 6600:
- MenuClass.TimeSearched = 7000;
- break;
- case 7600:
- MenuClass.TimeSearched = 8000;
- break;
- case 8600:
- MenuClass.TimeSearched = 9000;
- break;
- case 9600:
- MenuClass.TimeSearched = 10000;
- break;
- }
- if (MenuClass.TimeSearched == 600){
- MenuClass.TimeSearched = 1000;
- }
- switch(String(MenuClass.TimeSearched).length){
- case 1:
- CurrentTime = "00:0" + String(MenuClass.TimeSearched);
- break;
- case 2:
- CurrentTime = "00:" + String(MenuClass.TimeSearched);
- break;
- case 3:
- CurrentTime = "0" + String(MenuClass.TimeSearched).substring(0, 1) + ":" + String(MenuClass.TimeSearched).substring(1, 2) + String(MenuClass.TimeSearched).substring(2, 3);
- break;
- case 4:
- CurrentTime = String(MenuClass.TimeSearched).substring(0, 1) + String(MenuClass.TimeSearched).substring(1, 2) + ":" + String(MenuClass.TimeSearched).substring(2, 3) + String(MenuClass.TimeSearched).substring(3, 4);
- break;
- }
- ConnectingText.text = "Searching for game...\nCurrent time searched: " + CurrentTime;
- }
- private function MouseIsDown(Event:MouseEvent){
- if (LoginClass.RegisterButton.hitTestPoint(stage.mouseX, stage.mouseY)){
- if (LoginClass.RegisterText.text == "Done"){
- if (LoginClass.EnterName.text != "Please enter your desired username" && LoginClass.EnterPassword.text != "Please enter your desired password"){
- if (LoginClass.EnterName.text == ""){
- CreateMessageBox("Error: Please type in your desired username");
- }else if (LoginClass.EnterPassword.text == ""){
- CreateMessageBox("Error: Please type in your desired password");
- }else{
- LoginClass.LoggingIn = false;
- LogIn("Registering Account...");
- }
- }else{
- if (LoginClass.RegisterText.text == "Done"){
- CreateMessageBox("Error: Please type in desired username and password");
- }
- }
- }else{
- LoginClass.RegisterPage = true;
- LoginClass.StaticEnterName.text = "Register for Titan's Nebula";
- LoginClass.RegisterText.text = "Done";
- LoginClass.EnterName.text = "Please enter your desired username";
- LoginClass.EnterPassword.text = "Please enter your desired password";
- LoginClass.EnterName.textColor = 0x9F9F9F;
- LoginClass.EnterPassword.textColor = 0x9F9F9F;
- LoginClass.EnterPassword.displayAsPassword = false;
- loginClass.CreateBackButton();
- loginClass.CreateBackButtonText();
- stage.removeChild(LoginClass.LoginButton);
- stage.removeChild(LoginClass.LoginButtonText);
- }
- }
- if (MenuClass.GameChooseJoin.hitTestPoint(stage.mouseX, stage.mouseY)){
- CreateConnectingBox("Searching for game...\nCurrent time searched: 00:00");
- MenuClass.TimeSearcher.addEventListener(TimerEvent.TIMER, SearchingTime);
- MenuClass.TimeSearcher.start();
- ConnectionClass.TheConnection.disconnect();
- RoomName = "Info: " + AccountDetailsClass.Username;
- CurrentGame = "Info: " + AccountDetailsClass.Username;
- AccountDetailsClass.StoreUsername = AccountDetailsClass.Username;
- AccountDetailsClass.Username = "StoreGameBot2000";
- PlayerIOConnect();
- }
- if (FriendsClass.AddFriendsButton.hitTestPoint(stage.mouseX, stage.mouseY) && FriendsClass.FriendInputButton.stage == null){
- friendsClass.CreateAddFriendBox();
- }
- if (FriendsClass.FriendInputButton.hitTestPoint(stage.mouseX, stage.mouseY)){
- if (FriendsClass.Friends.indexOf(FriendsClass.FriendInput.text.toUpperCase()) != -1){
- CreateMessageBox("You've already added " + FriendsClass.FriendInput.text.toUpperCase());
- }else if (FriendsClass.FriendInput.text == ""){
- CreateMessageBox("Error: Please type in a username");
- }else{
- ConnectionClass.TheConnection.disconnect();
- AccountDetailsClass.StoreUsername = AccountDetailsClass.Username;
- AccountDetailsClass.Username = FriendsClass.FriendInput.text.toUpperCase();
- PlayerIOConnect();
- CreateConnectingBox("Adding friend...");
- MenuClass.SearchUser = true;
- }
- }
- if (MenuClass.GameChooseCreate.hitTestPoint(stage.mouseX, stage.mouseY)){
- menuClass.RemoveMenu();
- CreateConnectingBox("Creating game...");
- ConnectionClass.TheConnection.disconnect();
- RoomName = "Crte: " + AccountDetailsClass.Username;
- CurrentGame = "Crte: " + AccountDetailsClass.Username;
- AccountDetailsClass.StoreUsername = AccountDetailsClass.Username;
- AccountDetailsClass.Username = "StoreGameBot2000";
- PlayerIOConnect();
- CurrentHoster = AccountDetailsClass.StoreUsername;
- }
- if (!MenuClass.GameChooseBox.hitTestPoint(stage.mouseX, stage.mouseY) && MenuClass.GameChooseBox.stage != null){
- menuClass.RemoveGameChooseBox();
- }
- if (MenuClass.PlayButton.hitTestPoint(stage.mouseX, stage.mouseY)){
- menuClass.CreateGameChoose();
- }
- if (LoginClass.LoginButton.hitTestPoint(stage.mouseX, stage.mouseY)){
- if (LoginClass.EnterName.text != "Please enter your username" && LoginClass.EnterPassword.text != "Please enter your password"){
- if (LoginClass.EnterName.text == ""){
- CreateMessageBox("Error: Please enter your username in the text field");
- }else if (LoginClass.EnterPassword.text == ""){
- CreateMessageBox("Error: Please enter your password in the text field");
- }else{
- LoginClass.LoggingIn = true;
- LogIn("Logging In...");
- }
- }else{
- CreateMessageBox("Error: Please type in your username and password");
- }
- }
- if (LoginClass.BackButton.hitTestPoint(stage.mouseX, stage.mouseY)){
- LoginClass.RegisterPage = false;
- LoginClass.StaticEnterName.text = "Login to your Titan's Nebula Account";
- LoginClass.RegisterText.text = "Register";
- LoginClass.EnterName.text = "Please enter your username";
- LoginClass.EnterPassword.text = "Please enter your password";
- LoginClass.EnterPassword.displayAsPassword = false;
- LoginClass.EnterName.textColor = 0x9F9F9F;
- LoginClass.EnterPassword.textColor = 0x9F9F9F;
- stage.removeChild(LoginClass.BackButton);
- stage.removeChild(LoginClass.BackText);
- loginClass.CreateLoginButton();
- loginClass.CreateLoginButtonText();
- }
- if (MessageButton.hitTestPoint(stage.mouseX, stage.mouseY)){
- RemoveMessageBox();
- }
- if (CloseWindow.hitTestPoint(stage.mouseX, stage.mouseY)){
- RemoveConnectingBox();
- }
- if (CreateInGameButton.hitTestPoint(stage.mouseX, stage.mouseY) && GameNameText.text != "" && DescriptionText.text != "" && MaxPlayersText.text != ""){
- RoomName = "Room: " + GameNameText.text;
- CurrentDescription = DescriptionText.text;
- CurrentGame = "Room: " + RoomName;
- MaxPlayers = int(MaxPlayersText.text);
- RemoveConnectingBox();
- CurrentHoster = AccountDetailsClass.Username;
- ConnectionClass.TheConnection.send("CreateGame", CurrentGame, CurrentDescription, AccountDetailsClass.Username, CurrentAmount+1, Coop, MaxPlayers, 0);
- }
- for (var p:uint = 0; p < ShipClass.ChoosingShipArray.length; p++){
- if (ShipClass.ChoosingShipArray[p].hitTestPoint(stage.mouseX, stage.mouseY)){
- ShipClass.ShipChooser.graphics.clear();
- ShipClass.ShipChooser.graphics.lineStyle(1, 0x333333);
- ShipClass.ShipChooser.graphics.beginFill(0x0000FF, .2);
- ShipClass.ShipChooser.graphics.lineTo(65, 0);
- ShipClass.ShipChooser.graphics.lineTo(65, 65);
- ShipClass.ShipChooser.graphics.lineTo(0, 65);
- ShipClass.ShipChooser.graphics.lineTo(0, 0);
- ShipClass.ShipChooser.x = ShipClass.ChoosingShipArray[p].x-22;
- ShipClass.ShipChooser.y = ShipClass.ChoosingShipArray[p].y-18;
- ShipClass.ShipOutline = ShipClass.ChoosingShipArray[p].Outline;
- ShipClass.ShipFill = ShipClass.ChoosingShipArray[p].Fill;
- ShipClass.ShipDarkOutline = ShipClass.ChoosingShipArray[p].DarkOutline;
- }
- }
- if (JoinGameButton.hitTestPoint(stage.mouseX, stage.mouseY)){
- RoomName = LobbyGameDetails[CurrentGameSelected];
- CurrentGame = RoomName;
- CurrentHoster = LobbyGameDetails[CurrentGameSelected+2];
- CurrentDescription = LobbyGameDetails[CurrentGameSelected+1];
- Coop = LobbyGameDetails[CurrentGameSelected+3];
- ConnectionClass.TheConnection.send("SendLobbyDetails");
- JoiningGame = true;
- }
- if (StartGameButton.hitTestPoint(stage.mouseX, stage.mouseY) && FriendsClass.OnlineUsers.length > 0){
- ConnectionClass.TheConnection.send("StartGame", RoomName, CurrentHoster, RoomName);
- }
- if (LobbyButton.hitTestPoint(stage.mouseX, stage.mouseY) && LobbyButton.stage != null){
- RemoveChat();
- ConnectionClass.TheConnection.disconnect();
- PlayerIOConnect();
- CurrentGame = "Lobby1";
- RoomName = "Lobby1";
- CreateConnectingBox("Rejoining Lobby...");
- MenuClass.JoiningMenu = true;
- }
- if (MapTypeOptionBox.hitTestPoint(stage.mouseX, stage.mouseY)){
- MapTypeOptionBox.graphics.clear();
- MapTypeOptionBox.graphics.lineStyle(1, 0x333333);
- MapTypeOptionBox.graphics.beginFill(0x999999);
- MapTypeOptionBox.graphics.lineTo(40, 0);
- MapTypeOptionBox.graphics.lineTo(40, 25);
- MapTypeOptionBox.graphics.lineTo(0, 25);
- MapTypeOptionBox.graphics.lineTo(0, 0);
- MapTypeOptionBox.graphics.lineStyle(1, 0x333333);
- MapTypeOptionBox.graphics.beginFill(0x000000);
- MapTypeOptionBox.graphics.moveTo(5, 5);
- MapTypeOptionBox.graphics.lineTo(35, 5);
- MapTypeOptionBox.graphics.lineTo(35, 20);
- MapTypeOptionBox.graphics.lineTo(5, 20);
- MapTypeOptionBox.graphics.lineTo(5, 5);
- SecondMapOptionBox.graphics.clear();
- SecondMapOptionBox.graphics.lineStyle(1, 0x333333);
- SecondMapOptionBox.graphics.beginFill(0x999999);
- SecondMapOptionBox.graphics.lineTo(40, 0);
- SecondMapOptionBox.graphics.lineTo(40, 25);
- SecondMapOptionBox.graphics.lineTo(0, 25);
- SecondMapOptionBox.graphics.lineTo(0, 0);
- Coop = true;
- }
- if (SecondMapOptionBox.hitTestPoint(stage.mouseX, stage.mouseY)){
- SecondMapOptionBox.graphics.clear();
- SecondMapOptionBox.graphics.lineStyle(1, 0x333333);
- SecondMapOptionBox.graphics.beginFill(0x999999);
- SecondMapOptionBox.graphics.lineTo(40, 0);
- SecondMapOptionBox.graphics.lineTo(40, 25);
- SecondMapOptionBox.graphics.lineTo(0, 25);
- SecondMapOptionBox.graphics.lineTo(0, 0);
- SecondMapOptionBox.graphics.lineStyle(1, 0x333333);
- SecondMapOptionBox.graphics.beginFill(0x000000);
- SecondMapOptionBox.graphics.moveTo(5, 5);
- SecondMapOptionBox.graphics.lineTo(35, 5);
- SecondMapOptionBox.graphics.lineTo(35, 20);
- SecondMapOptionBox.graphics.lineTo(5, 20);
- SecondMapOptionBox.graphics.lineTo(5, 5);
- MapTypeOptionBox.graphics.clear();
- MapTypeOptionBox.graphics.lineStyle(1, 0x333333);
- MapTypeOptionBox.graphics.beginFill(0x999999);
- MapTypeOptionBox.graphics.lineTo(40, 0);
- MapTypeOptionBox.graphics.lineTo(40, 25);
- MapTypeOptionBox.graphics.lineTo(0, 25);
- MapTypeOptionBox.graphics.lineTo(0, 0);
- Coop = false;
- }
- if (!HealthClass.Reviving && !PauseGame){
- ShipClass.Shooting = true;
- ShipClass.BulletTimer.start();
- }
- }
- private function MouseIsUp(Event:MouseEvent){
- DraggingGame = false;
- DraggingWindow = false;
- if (!PauseGame){
- ShipClass.Shooting = false;
- ShipClass.BulletTimer.reset();
- ShipClass.BulletTimer.stop();
- }
- }
- private function EnterFrameFunction(event:Event){
- if (SpellClass.CastSpell){
- SpellClass.CastingScroll.scaleX += SpellClass.CastingTime;
- for (var g:uint = 0; g < SpellClass.CastingCircleArray.length; g++){
- if (g > SpellClass.CastingCircleArray.length/2){
- SpellClass.CastingCircleArray[g].degrees = SpellClass.CastingCircleArray[g].degrees + 20;
- }else{
- SpellClass.CastingCircleArray[g].degrees = SpellClass.CastingCircleArray[g].degrees - 20;
- }
- var radians = SpellClass.CastingCircleArray[g].degrees * Math.PI / 180;
- SpellClass.CastingCircleArray[g].x += Math.sin(radians) * SpellClass.CastingCircleArray[g].radius;
- SpellClass.CastingCircleArray[g].y += Math.cos(radians) * SpellClass.CastingCircleArray[g].radius;
- SpellClass.CastingCircleArray[g].alpha -= SpellClass.CastingTime;
- particleClass.CreateTrail(SpellClass.CastingCircleArray[g].Colour, "PlayerThrust", SpellClass.CastingCircleArray[g].x, SpellClass.CastingCircleArray[g].y);
- }
- if (SpellClass.CastingScroll.scaleX >= 1){
- SpellClass.CastingScroll.scaleX = 0;
- stage.removeChild(SpellClass.CastingScroll);
- stage.removeChild(SpellClass.CastingBar);
- stage.removeChild(SpellClass.CastingText);
- spellClass.CreateSpell(SpellClass.CurrentSpell);
- SpellClass.CurrentSpell = "";
- SpellClass.CastSpell = false;
- for (var d:uint = SpellClass.CastingCircleArray.length-1; d > -1; d--){
- stage.removeChild(SpellClass.CastingCircleArray[d]);
- SpellClass.CastingCircleArray.splice(d, 1);
- }
- }
- }
- if (SpellClass.ThunderSpellTimer.running){
- SpellClass.NewLine.graphics.clear();
- }
- if (!PauseGame && !RejoinChat){
- particleClass.CreateStars();
- ManageGameStatements();
- ManageBulletLoop();
- manageEnemyClass.ManageEnemyBulletLoop();
- ManageParticleLoop();
- ManageTrailLoop();
- ManageTextLoop();
- ManageStarLoop();
- ManageUpgradesLoop();
- manageEnemyClass.ManageEnemyLoop();
- if (!HealthClass.Reviving){
- if (stage.mouseX <= 850 || ShipClass.Ship.x <= 850){
- if (stage.mouseX >= 0 || ShipClass.Ship.x >= 0){
- if (stage.mouseY >= 0 || ShipClass.Ship.y >= 0){
- if (stage.mouseY <= 650 || ShipClass.Ship.y <= 650){
- MoveShip();
- }
- }
- }
- }
- particleClass.CreateTrail(ShipClass.ShipDarkOutline, "Thrust", 0, 0);
- }
- for (var b:uint = 0; b < ShipClass.ShipArray.length; b++){
- if (ShipClass.ShipArray[b] != AccountDetailsClass.Username){
- MovePlayerShip(b, ShipClass.TheSpeedX[b]);
- }
- }
- }
- if (CurrentGame.substring(0, 6) == "Game: "){
- MoneyDisplay.text = String(AccountDetailsClass.Money);
- MenuClass.TheBackground.y += 12;
- if (MenuClass.TheBackground.y > 1400){
- MenuClass.TheBackground.y = 20;
- }
- if (HealthClass.Mana < HealthClass.MaxMana){
- HealthClass.Mana += .2;
- }
- HealthClass.ManaScroll.scaleX = (HealthClass.Mana/HealthClass.MaxMana);
- HealthClass.HealthScroll.scaleX = (HealthClass.Health/HealthClass.MaxHealth);
- }
- if (FadeMusic){
- MusicTransform.volume = MusicVolume;
- MusicChannel.soundTransform = MusicTransform;
- MusicVolume -= .02;
- if (MusicVolume <= 0){
- FadeMusic = false;
- }
- }
- var LoginBoxText:String = "";
- var PasswordBoxText:String = "";
- if (LoginClass.RegisterPage){
- LoginBoxText = "Please enter your desired username";
- PasswordBoxText = "Please enter your desired password";
- }else{
- LoginBoxText = "Please enter your username";
- PasswordBoxText = "Please enter your password";
- }
- if (stage.focus != LoginClass.EnterName && LoginClass.EnterName.text == ""){
- LoginClass.EnterName.text = LoginBoxText;
- LoginClass.EnterName.textColor = 0x9F9F9F;
- LoginClass.EnterName.maxChars = 200;
- }else if (stage.focus == LoginClass.EnterName){
- if (LoginClass.EnterName.text == LoginBoxText){
- LoginClass.EnterName.text = "";
- LoginClass.EnterName.textColor = 0x000000;
- LoginClass.EnterName.maxChars = 15;
- }
- }
- if (stage.focus != LoginClass.EnterPassword && LoginClass.EnterPassword.text == ""){
- LoginClass.EnterPassword.text = PasswordBoxText;
- LoginClass.EnterPassword.textColor = 0x9F9F9F;
- LoginClass.EnterPassword.maxChars = 200;
- LoginClass.EnterPassword.displayAsPassword = false;
- }else if (stage.focus == LoginClass.EnterPassword){
- if (LoginClass.EnterPassword.text == PasswordBoxText){
- LoginClass.EnterPassword.text = "";
- LoginClass.EnterPassword.textColor = 0x000000;
- LoginClass.EnterPassword.maxChars = 20;
- LoginClass.EnterPassword.displayAsPassword = true;
- }
- }
- if (FriendsClass.FriendInput.stage != null){
- if (stage.focus != FriendsClass.FriendInput && FriendsClass.FriendInput.text == ""){
- FriendsClass.FriendInput.text = "Type in your friend's name";
- FriendsClass.FriendInput.textColor = 0x333333;
- FriendsClass.FriendInput.maxChars = 200;
- }else if (stage.focus == FriendsClass.FriendInput){
- if (FriendsClass.FriendInput.text == "Type in your friend's name"){
- FriendsClass.FriendInput.text = "";
- FriendsClass.FriendInput.textColor = 0x000000;
- FriendsClass.FriendInput.maxChars = 20;
- }
- }
- }
- for (var p:uint = 0; p < FriendsClass.MouseOverGlowArray.length; p++){
- if (FriendsClass.MouseOverGlowArray[p] != null){
- if (FriendsClass.MouseOverGlowArray[p].hitTestPoint(stage.mouseX, stage.mouseY)){
- var ButtonGlowFilter = new GlowFilter(FriendsClass.ColourGlowArray[p], 1, 10, 10, 1, 1, false, false);
- FriendsClass.MouseOverGlowArray[p].filters = [ButtonGlowFilter];
- }else{
- FriendsClass.MouseOverGlowArray[p].filters = [];
- }
- }
- }
- }
- private function RemoveConnectingBox():void{
- if (FriendsClass.GreyScreen.stage != null){
- stage.removeChild(FriendsClass.GreyScreen);
- }
- if (ConnectingBox.stage != null){
- stage.removeChild(ConnectingBox);
- }
- if (ConnectingText.stage != null){
- stage.removeChild(ConnectingText);
- }
- FriendsClass.GreyScreen.graphics.clear();
- ConnectingBox.graphics.clear();
- ConnectingText.text = "";
- }
- private function CreateConnectingBox(ConnectMessage):void{
- FriendsClass.GreyScreen.graphics.clear();
- ConnectingBox.graphics.clear();
- FriendsClass.GreyScreen.graphics.lineStyle(1, 0x333333);
- FriendsClass.GreyScreen.graphics.beginFill(0x999999);
- FriendsClass.GreyScreen.graphics.lineTo(850, 0);
- FriendsClass.GreyScreen.graphics.lineTo(850, 650);
- FriendsClass.GreyScreen.graphics.lineTo(0, 650);
- FriendsClass.GreyScreen.graphics.lineTo(0, 0);
- FriendsClass.GreyScreen.alpha = .5;
- stage.addChild(FriendsClass.GreyScreen);
- ConnectingBox.graphics.lineStyle(1, 0x333333);
- ConnectingBox.graphics.beginFill(0x999999);
- ConnectingBox.graphics.lineTo(250, 0);
- ConnectingBox.graphics.lineTo(250, 100);
- ConnectingBox.graphics.lineTo(0, 100);
- ConnectingBox.graphics.lineTo(0, 0);
- ConnectingBox.x = 300;
- ConnectingBox.y = 150;
- ConnectingBox.alpha = .8;
- stage.addChild(ConnectingBox);
- stage.addChild(ConnectingText);
- ConnectingText.embedFonts = true;
- var NameProperties:TextFormat = new TextFormat();
- NameProperties.font = myFont.fontName;
- NameProperties.align = "center";
- ConnectingText.defaultTextFormat = NameProperties;
- ConnectingText.x = 180;
- ConnectingText.y = 180;
- ConnectingText.width = 500;
- ConnectingText.height = 50;
- ConnectingText.selectable = false;
- ConnectingText.text = ConnectMessage;
- }
- private function CreateMessageBox(TheMessage):void{
- MessageBox.graphics.clear();
- MessageButton.graphics.clear();
- if (FriendsClass.GreyScreen.stage == null){
- FriendsClass.GreyScreen.graphics.clear();
- FriendsClass.GreyScreen.graphics.lineStyle(1, 0x333333);
- FriendsClass.GreyScreen.graphics.beginFill(0x999999);
- FriendsClass.GreyScreen.graphics.lineTo(850, 0);
- FriendsClass.GreyScreen.graphics.lineTo(850, 650);
- FriendsClass.GreyScreen.graphics.lineTo(0, 650);
- FriendsClass.GreyScreen.graphics.lineTo(0, 0);
- FriendsClass.GreyScreen.alpha = .5;
- stage.addChild(FriendsClass.GreyScreen);
- }
- MessageBox.graphics.lineStyle(1, 0x333333);
- MessageBox.graphics.beginFill(0x999999);
- MessageBox.graphics.lineTo(250, 0);
- MessageBox.graphics.lineTo(250, 150);
- MessageBox.graphics.lineTo(0, 150);
- MessageBox.graphics.lineTo(0, 0);
- MessageBox.x = 300;
- MessageBox.y = 150;
- MessageBox.alpha = .8;
- stage.addChild(MessageBox);
- stage.addChild(TheMessageText);
- TheMessageText.embedFonts = true;
- var NameProperties:TextFormat = new TextFormat();
- NameProperties.font = myFont.fontName;
- NameProperties.align = "center";
- TheMessageText.defaultTextFormat = NameProperties;
- TheMessageText.x = 320;
- TheMessageText.y = 180;
- TheMessageText.width = 200;
- TheMessageText.height = 200;
- TheMessageText.selectable = false;
- TheMessageText.text = TheMessage;
- TheMessageText.multiline = true;
- TheMessageText.wordWrap = true;
- MessageButton.graphics.lineStyle(1, 0x333333);
- MessageButton.graphics.beginFill(0x999999);
- MessageButton.graphics.lineTo(75, 0);
- MessageButton.graphics.lineTo(75, 25);
- MessageButton.graphics.lineTo(0, 25);
- MessageButton.graphics.lineTo(0, 0);
- MessageButton.x = 430;
- MessageButton.y = 260;
- MessageButton.alpha = .8;
- stage.addChild(MessageButton);
- FriendsClass.MouseOverGlowArray[3] = MessageButton;
- FriendsClass.ColourGlowArray[3] = 0xD2C400;
- stage.addChild(MessageButtonText);
- MessageButtonText.embedFonts = true;
- var NameProperties2:TextFormat = new TextFormat();
- NameProperties2.font = myFont.fontName;
- MessageButtonText.defaultTextFormat = NameProperties2;
- MessageButtonText.x = 450;
- MessageButtonText.y = 265;
- MessageButtonText.width = 500;
- MessageButtonText.height = 25;
- MessageButtonText.selectable = false;
- MessageButtonText.text = "Ok";
- }
- private function RemoveMessageBox():void{
- if (FriendsClass.GreyScreen.stage != null){
- stage.removeChild(FriendsClass.GreyScreen);
- }
- stage.removeChild(MessageBox);
- stage.removeChild(TheMessageText);
- stage.removeChild(MessageButton);
- stage.removeChild(MessageButtonText);
- FriendsClass.GreyScreen.graphics.clear();
- MessageBox.graphics.clear();
- MessageButton.graphics.clear();
- TheMessageText.text = "";
- MessageButton.text = "";
- }
- private function CreateInGameChat(Amount:String):void{
- if (Amount != "ChatText"){
- stage.addChild(ChatClass.ChatBox);
- ChatClass.ChatBox.embedFonts = true;
- var NameProperties:TextFormat = new TextFormat();
- NameProperties.font = myFont.fontName;
- ChatClass.ChatBox.defaultTextFormat = NameProperties;
- ChatClass.ChatBox.x = 20;
- ChatClass.ChatBox.y = 600;
- ChatClass.ChatBox.width = 200;
- ChatClass.ChatBox.height = 20;
- ChatClass.ChatBox.border = true;
- ChatClass.ChatBox.borderColor = 0xFFFFFF;
- ChatClass.ChatBox.type = TextFieldType.INPUT;
- ChatClass.ChatBox.textColor = 0xFFFFFF;
- stage.focus = ChatClass.ChatBox;
- }
- if (Amount != "ChatBox"){
- stage.addChild(ChatClass.ChatText);
- ChatClass.ChatText.embedFonts = true;
- var NameProperties2:TextFormat = new TextFormat();
- NameProperties2.font = myFont.fontName;
- ChatClass.ChatText.defaultTextFormat = NameProperties2;
- ChatClass.ChatText.x = 620;
- ChatClass.ChatText.y = 520;
- ChatClass.ChatText.width = 200;
- ChatClass.ChatText.height = 400;
- ChatClass.ChatText.border = false;
- ChatClass.ChatText.selectable = false;
- ChatClass.ChatText.multiline = true;
- ChatClass.ChatText.wordWrap = true;
- ChatClass.ChatText.textColor = 0xFFFFFF;
- }
- }
- private function RemoveChat():void{
- stage.removeChild(ChatClass.ChatBox);
- stage.removeChild(ChatClass.ChatText);
- stage.removeChild(ChatClass.ChatUsers);
- stage.removeChild(ChatClass.ChatBoxFill);
- stage.removeChild(ChatClass.ChatTextFill);
- stage.removeChild(ChatClass.ChatUsersFill);
- if (AccountDetailsClass.Username == CurrentHoster){
- stage.removeChild(StartGameButton);
- stage.removeChild(StartGameText);
- StartGameButton.graphics.clear();
- }
- stage.removeChild(LobbyButton);
- LobbyButton = new MovieClip();
- ChatClass.ChatBox.text = "";
- ChatClass.ChatText.text = "";
- }
- private function CreateStartGameButton():void{
- StartGameButton.graphics.lineStyle(1, 0x333333);
- StartGameButton.graphics.beginFill(0x999999);
- StartGameButton.graphics.lineTo(100, 0);
- StartGameButton.graphics.lineTo(100, 40);
- StartGameButton.graphics.lineTo(0, 40);
- StartGameButton.graphics.lineTo(0, 0);
- StartGameButton.x = 540;
- StartGameButton.y = 450;
- StartGameButton.alpha = .8;
- stage.addChild(StartGameButton);
- stage.addChild(StartGameText);
- StartGameText.embedFonts = true;
- var NameProperties3:TextFormat = new TextFormat();
- NameProperties3.font = myFont.fontName;
- StartGameText.defaultTextFormat = NameProperties3;
- StartGameText.x = 555;
- StartGameText.y = 455;
- StartGameText.width = 100;
- StartGameText.height = 25;
- StartGameText.selectable = false;
- StartGameText.text = "Start Game";
- }
- private function CreateMainGame():void{
- trace("Creating Game");
- stage.removeChild(MenuClass.BigPicture);
- trace("Removed BigPicture");
- stage.addChild(MenuClass.TheBackground);
- trace("Created TheBackground");
- DrawShip();
- trace("DrewShip");
- CreateHealthBar();
- trace("Created Health Bar");
- CreateManaBar();
- trace("Created Mana Bar");
- CreateSpellsBox("Heal", 50, 600);
- CreateSpellsBox("ThunderArea", 130, 600);
- CreateSpellsBox("HolyShield", 200, 600);
- trace("Created Spell Boxes");
- CreateGameEvents();
- trace("Created Game Events");
- particleClass.CreateText(200, 150, 30, "Prepare yourself for Wave 1", 0xA10097, 80, "Nothing");
- particleClass.CreateText(250, 200, 30, WaveClass.WaveNames[WaveClass.CurrentWave], 0xFFFFFF, 50, "Nothing");
- trace("Created Text");
- CreateMoneyText();
- trace("Created Money Text");
- MusicChannel = gameMusic.play(0, 99);
- MusicTransform.volume = 1;
- MusicChannel.soundTransform = MusicTransform;
- PauseGame = false;
- ShipClass.WaitingChat = false;
- stage.addChild(SpellClass.NewLine);
- CreateInGameChat("ChatText");
- }
- private function CreateGameEvents():void{
- EnemyClass.EnemyTimer.addEventListener(TimerEvent.TIMER, EnemyTimerComplete);
- ShipClass.BulletTimer.addEventListener(TimerEvent.TIMER, ShootBullet);
- HealthClass.ReviveTimer.addEventListener(TimerEvent.TIMER, ReviveShip);
- HealthClass.FlashTimer.addEventListener(TimerEvent.TIMER, FlashTimerComplete);
- ShipClass.MovementTimer.addEventListener(TimerEvent.TIMER, SendMovementConnections);
- WaveClass.NextWaveTimer.addEventListener(TimerEvent.TIMER, NextWave);
- EnemyClass.EndOfStageTimer.addEventListener(TimerEvent.TIMER, EndStage);
- WaveClass.NextWaveTimer.start();
- ShipClass.MovementTimer.start();
- }
- private function EndStage(Event:TimerEvent){
- EnemyClass.EndOfStageTimer.reset();
- EnemyClass.EndOfStageTimer.stop();
- stage.addChild(MenuClass.TitleBackground);
- MenuClass.TitleBackground.alpha = .2;
- EnemyClass.StageEnd = true;
- RejoinChat = true;
- ShipClass.MovementTimer.stop();
- EnemyClass.EnemyTimer.stop();
- ShipClass.BulletTimer.stop();
- HealthClass.ReviveTimer.stop();
- HealthClass.FlashTimer.stop();
- WaveClass.NextWaveTimer.stop();
- RemoveMainGame();
- RoomName = "Room: " + RoomName.substring(7, RoomName.length);
- CurrentGame = "Room: " + RoomName.substring(7, RoomName.length);
- CreateConnectingBox("Rejoining Chat...");
- ConnectionClass.TheConnection.disconnect();
- PlayerIOConnect();
- }
- private function RemoveMainGame():void{
- for (var j:int = ParticleClass.StarsArray.length-1; j > -1; j--){
- stage.removeChild(ParticleClass.StarsArray[j]);
- ParticleClass.StarsArray.splice(j, 1);
- }
- for (var i:int = EnemyClass.EnemyArray.length-1; i > -1; i--){
- stage.removeChild(EnemyClass.EnemyArray[i]);
- EnemyClass.EnemyArray.splice(i, 1);
- }
- for (var c:int = ShipClass.ShipArray.length-1; c > -1; c--){
- stage.removeChild(ShipClass.ShipArray[c]);
- ShipClass.ShipArray.splice(c, 1);
- }
- for (var l:int = ShipClass.BulletArray.length-1; l > -1; l--){
- stage.removeChild(ShipClass.BulletArray[l]);
- ShipClass.BulletArray.splice(l, 1);
- }
- for (var p:int = EnemyClass.EnemyBulletArray.length-1; p > -1; p--){
- stage.removeChild(EnemyClass.EnemyBulletArray[p]);
- EnemyClass.EnemyBulletArray.splice(p, 1);
- }
- for (var t:int = ParticleClass.TrailArray.length-1; t > -1; t--){
- stage.removeChild(ParticleClass.TrailArray[t]);
- ParticleClass.TrailArray.splice(t, 1);
- }
- for (var n:int = ParticleClass.TextArray.length-4; n > -1; n -= 4){
- stage.removeChild(ParticleClass.TextArray[n]);
- ParticleClass.TextArray.splice(n, 4);
- }
- stage.removeChild(ShipClass.Ship);
- stage.removeChild(MoneyDisplay);
- stage.removeChild(HealthClass.HealthScroll);
- stage.removeChild(HealthClass.HealthBar);
- stage.removeChild(MenuClass.TheBackground);
- }
- private function MoveShip():void{
- ShipClass.SpeedX = (stage.mouseX-ShipClass.Ship.x-12)/ShipClass.ShipSpeed;
- ShipClass.SpeedY = (stage.mouseY-ShipClass.Ship.y-12)/ShipClass.ShipSpeed/2;
- if (ShipClass.SpeedX >= ShipClass.maxSpeed){
- ShipClass.SpeedX = ShipClass.maxSpeed;
- }
- if (ShipClass.SpeedY >= ShipClass.maxSpeed){
- ShipClass.SpeedY = ShipClass.maxSpeed;
- }
- if (ShipClass.SpeedX <= -ShipClass.maxSpeed){
- ShipClass.SpeedX = -ShipClass.maxSpeed;
- }
- if (ShipClass.SpeedY <= -ShipClass.maxSpeed){
- ShipClass.SpeedY = -ShipClass.maxSpeed;
- }
- if (!SpellClass.CastSpell){
- ShipClass.Ship.x += ShipClass.SpeedX;
- ShipClass.Ship.y += ShipClass.SpeedY;
- }
- var distanceX:Number = 0;
- var dx = ShipClass.Ship.x-stage.mouseX;
- distanceX = Math.round(Math.sqrt((dx*dx)))/5-2;
- if (stage.mouseX >= ShipClass.Ship.x){
- if (distanceX >= 20){
- distanceX = 20;
- }
- }else{
- if (distanceX >= 10){
- distanceX = 10;
- }
- }
- if (SpellClass.CastSpell){
- distanceX = 0;
- ShipClass.SpeedX = 0;
- }
- ShipClass.Ship.graphics.clear();
- ShipClass.Ship.graphics.lineStyle(2, ShipClass.ShipOutline);
- ShipClass.Ship.graphics.beginFill(ShipClass.ShipFill, 1-Math.abs(ShipClass.SpeedX)/40);
- if (stage.mouseX <= ShipClass.Ship.x){
- //Creating the basic shape of the ship
- ShipClass.Ship.graphics.lineTo(25-distanceX, 0-distanceX);
- ShipClass.Ship.graphics.lineTo(55-distanceX, 25-distanceX);
- ShipClass.Ship.graphics.lineTo(-25+distanceX, 25+distanceX);
- ShipClass.Ship.graphics.lineTo(0, 0);
- //Creating shading to the back of the ship
- ShipClass.Ship.graphics.beginFill(ShipClass.ShipDarkOutline, .8);
- ShipClass.Ship.graphics.lineStyle(1, ShipClass.ShipDarkOutline, .8);
- ShipClass.Ship.graphics.moveTo(-20+distanceX, 20+distanceX);
- ShipClass.Ship.graphics.lineTo(50-distanceX, 20-distanceX);
- ShipClass.Ship.graphics.lineTo(55-distanceX, 25-distanceX);
- ShipClass.Ship.graphics.lineTo(-25+distanceX, 25+distanceX);
- //Creating Back model of the ship
- ShipClass.Ship.graphics.beginFill(ShipClass.BackShipColour, 1-Math.abs(ShipClass.SpeedX)/40);
- ShipClass.Ship.graphics.lineStyle(1, ShipClass.ShipOutline, .8);
- ShipClass.Ship.graphics.moveTo(55-distanceX, 25-distanceX);
- ShipClass.Ship.graphics.lineTo(55-distanceX, 32-distanceX);
- ShipClass.Ship.graphics.lineTo(-25+distanceX, 32+distanceX);
- ShipClass.Ship.graphics.lineTo(-25+distanceX, 25+distanceX);
- //Creating the right missle on the ship
- ShipClass.Ship.graphics.beginFill(ShipClass.ShipFill, .8);
- ShipClass.Ship.graphics.lineStyle(1, ShipClass.ShipOutline, 1-ShipClass.SpeedX/40);
- ShipClass.Ship.graphics.moveTo(33-distanceX, 5-distanceX);
- ShipClass.Ship.graphics.lineTo(50-distanceX, 5-distanceX);
- ShipClass.Ship.graphics.lineTo(55-distanceX, 25-distanceX);
- ShipClass.Ship.graphics.lineTo(33-distanceX, 5-distanceX);
- //Creating the left missle on the ship
- ShipClass.Ship.graphics.beginFill(ShipClass.ShipFill, 1-ShipClass.SpeedX/25);
- ShipClass.Ship.graphics.lineStyle(1, ShipClass.ShipOutline, 1-ShipClass.SpeedX/25);
- ShipClass.Ship.graphics.moveTo(-4, 5);
- ShipClass.Ship.graphics.lineTo(-21+distanceX, 5+distanceX);
- ShipClass.Ship.graphics.lineTo(-26+distanceX, 25+distanceX);
- ShipClass.Ship.graphics.lineTo(-4, 5);
- }else{
- distanceX = distanceX/1.8;
- //Creating the left missle on the ship
- ShipClass.Ship.graphics.beginFill(ShipClass.ShipFill, 1-Math.abs(ShipClass.SpeedX)/40);
- ShipClass.Ship.graphics.lineStyle(1, ShipClass.ShipOutline, .8);
- ShipClass.Ship.graphics.moveTo(-4+distanceX, 5-distanceX/2);
- ShipClass.Ship.graphics.lineTo(-21+distanceX, 5-distanceX/2);
- ShipClass.Ship.graphics.lineTo(-26+distanceX, 25-distanceX/2);
- ShipClass.Ship.graphics.lineTo(-4+distanceX, 5-distanceX/2);
- //Creating the basic shape of the ship
- ShipClass.Ship.graphics.lineStyle(2, ShipClass.ShipOutline);
- ShipClass.Ship.graphics.beginFill(ShipClass.ShipFill, 1-ShipClass.SpeedX/40);
- ShipClass.Ship.graphics.moveTo(0, 0);
- ShipClass.Ship.graphics.lineTo(25-distanceX, 0+distanceX);
- ShipClass.Ship.graphics.lineTo(55-distanceX, 25+distanceX);
- ShipClass.Ship.graphics.lineTo(-25+distanceX, 25-distanceX);
- ShipClass.Ship.graphics.lineTo(0, 0);
- //Creating shading to the back of the ship
- ShipClass.Ship.graphics.beginFill(ShipClass.ShipDarkOutline, .8);
- ShipClass.Ship.graphics.lineStyle(1, ShipClass.ShipDarkOutline, .8);
- ShipClass.Ship.graphics.moveTo(-20+distanceX, 20-distanceX);
- ShipClass.Ship.graphics.lineTo(50-distanceX, 20+distanceX);
- ShipClass.Ship.graphics.lineTo(55-distanceX, 25+distanceX);
- ShipClass.Ship.graphics.lineTo(-25+distanceX, 25-distanceX);
- //Creating Back model of the ship
- ShipClass.Ship.graphics.beginFill(ShipClass.BackShipColour, 1-ShipClass.SpeedX/40);
- ShipClass.Ship.graphics.lineStyle(1, ShipClass.ShipOutline, .8);
- ShipClass.Ship.graphics.moveTo(55-distanceX, 25+distanceX);
- ShipClass.Ship.graphics.lineTo(55-distanceX, 32+distanceX);
- ShipClass.Ship.graphics.lineTo(-25+distanceX, 32-distanceX);
- ShipClass.Ship.graphics.lineTo(-25+distanceX, 25-distanceX);
- //Creating the right missle on the ship
- ShipClass.Ship.graphics.beginFill(ShipClass.ShipFill, 1-ShipClass.SpeedX/50);
- ShipClass.Ship.graphics.lineStyle(1, ShipClass.ShipOutline, 1-ShipClass.SpeedX/50);
- ShipClass.Ship.graphics.moveTo(33-distanceX, 5+distanceX);
- ShipClass.Ship.graphics.lineTo(50-distanceX, 5+(distanceX*2));
- ShipClass.Ship.graphics.lineTo(55-distanceX, 25+distanceX);
- ShipClass.Ship.graphics.lineTo(33-distanceX, 5+distanceX);
- }
- ShipClass.Ship.scaleX = .7;
- ShipClass.Ship.scaleY = .7;
- }
- private function DrawShip():void{
- ShipClass.Ship.graphics.lineStyle(1, 0x00BD30);
- ShipClass.Ship.graphics.lineTo(25, 0);
- ShipClass.Ship.graphics.lineTo(55, 25);
- ShipClass.Ship.graphics.lineTo(-25, 25);
- ShipClass.Ship.graphics.lineTo(0, 0);
- stage.addChild(ShipClass.Ship);
- ShipClass.Ship.x = 300;
- ShipClass.Ship.y = 300;
- }
- private function CreateNewShip(TheUsername:String, ColourOutline:int, ColourFill:int, ColourDarkOutline:int):void{
- var ship:MovieClip = new MovieClip();
- ship.graphics.lineStyle(1, 0x00BD30);
- ship.graphics.lineTo(25, 0);
- ship.graphics.lineTo(55, 25);
- ship.graphics.lineTo(-25, 25);
- ship.graphics.lineTo(0, 0);
- stage.addChild(ship);
- ship.x = 300;
- ship.y = 300;
- ShipClass.ShipArray.push(ship);
- ShipClass.ShipArray[ShipClass.ShipArray.length-1].Username = TheUsername;
- ShipClass.ShipArray[ShipClass.ShipArray.length-1].Outline = ColourOutline;
- ShipClass.ShipArray[ShipClass.ShipArray.length-1].Fill = ColourFill;
- ShipClass.ShipArray[ShipClass.ShipArray.length-1].DarkOutline = ColourDarkOutline;
- }
- private function CreateBullet(Bunches:uint, X:int, Y:int, TheBulletType:String):void{
- trace("Creating Bullet");
- var Bullet:MovieClip = new MovieClip();
- var BulletGlowFilter;
- var BulletGlowFilter2;
- switch (TheBulletType){
- case "RedLaser":
- BulletGlowFilter = new GlowFilter(0xFF0000, 1, 10, 10, 1, 1, false, false);
- Bullet.filters = [BulletGlowFilter];
- Bullet.graphics.lineStyle(2, 0xFF0000);
- Bullet.graphics.lineTo(0, 20);
- break;
- case "GoldBullet":
- BulletGlowFilter = new GlowFilter(0xA87800, 1, 10, 10, 1, 1, false, false);
- BulletGlowFilter2 = new GlowFilter(0xFFCC33, 1, 15, 15, 4, 1, true, false);
- Bullet.filters = [BulletGlowFilter];
- Bullet.graphics.lineStyle(2, 0xA87800);
- Bullet.graphics.lineTo(5, 0);
- Bullet.graphics.lineTo(5, 25);
- Bullet.graphics.lineTo(0, 25);
- Bullet.graphics.lineTo(0, 0);
- break;
- case "BlueBullet":
- BulletGlowFilter = new GlowFilter(0x0006C2, 1, 10, 10, 1, 1, false, false);
- Bullet.filters = [BulletGlowFilter];
- Bullet.graphics.lineStyle(2, 0x0006C2);
- Bullet.graphics.beginFill(0x0008E9);
- Bullet.graphics.lineTo(5, 15);
- Bullet.graphics.lineTo(10, 0);
- Bullet.graphics.lineTo(5, -15);
- Bullet.graphics.lineTo(0, 0);
- break;
- case "GreenBullet":
- BulletGlowFilter = new GlowFilter(0x00FF00, 1, 10, 10, 2, 1, false, false);
- Bullet.filters = [BulletGlowFilter];
- Bullet.graphics.lineStyle(1, 0x00FF00);
- Bullet.graphics.lineTo(5, 2.5);
- Bullet.graphics.lineTo(0, 5);
- Bullet.graphics.lineTo(5, 7.5);
- Bullet.graphics.lineTo(0, 10);
- Bullet.graphics.lineTo(5, 12.5);
- Bullet.graphics.lineTo(0, 15);
- Bullet.graphics.lineTo(5, 17.5);
- Bullet.graphics.lineTo(0, 20);
- break;
- case "PlasmaBullet":
- BulletGlowFilter = new GlowFilter(0xFFFFCC, 1, 10, 10, 2, 1, false, false);
- BulletGlowFilter2 = new GlowFilter(0x990099, 1, 10, 10, 2, 1, true, false);
- Bullet.filters = [BulletGlowFilter2, BulletGlowFilter];
- Bullet.graphics.lineStyle(1, 0xFFFFCC);
- Bullet.graphics.beginFill(0xFFFFCC);
- Bullet.graphics.drawCircle(0, 0, 5);
- break;
- case "EvilPlasmaBullet":
- BulletGlowFilter = new GlowFilter(0x000000, 1, 10, 10, 2, 1, true, false);
- BulletGlowFilter2 = new GlowFilter(0xFF0000, 1, 10, 10, 4, 1, false, false);
- Bullet.filters = [BulletGlowFilter, BulletGlowFilter2];
- Bullet.graphics.lineStyle(1, 0x000000);
- Bullet.graphics.beginFill(0xFFFFFF);
- Bullet.graphics.drawCircle(0, 0, 5);
- break;
- case "ForkBullet":
- BulletGlowFilter = new GlowFilter(0x0000FF, 1, 10, 10, 4, 1, false, false);
- Bullet.filters = [BulletGlowFilter];
- Bullet.graphics.lineStyle(1, 0x00CCFF);
- Bullet.graphics.lineTo(5, 3);
- Bullet.graphics.lineTo(5, 8);
- Bullet.graphics.lineTo(10, 11);
- Bullet.graphics.lineTo(10, 16);
- Bullet.graphics.lineTo(15, 19);
- Bullet.graphics.lineTo(15, 24);
- Bullet.graphics.lineTo(15, 19);
- Bullet.graphics.lineTo(20, 16);
- Bullet.graphics.lineTo(20, 11);
- Bullet.graphics.lineTo(25, 8);
- Bullet.graphics.lineTo(25, 3);
- Bullet.graphics.lineTo(30, 0);
- Bullet.rotation = 180;
- break;
- case "ArrowBullet":
- BulletGlowFilter = new GlowFilter(0x9900CC, 1, 10, 10, 1, 1, false, false);
- Bullet.filters = [BulletGlowFilter];
- Bullet.graphics.lineStyle(1, 0x9900CC);
- Bullet.graphics.beginFill(0xFF0000);
- Bullet.graphics.lineTo(5, 10);
- Bullet.graphics.lineTo(2, 13);
- Bullet.graphics.lineTo(6, 20);
- Bullet.graphics.lineTo(-6, 20);
- Bullet.graphics.lineTo(-2, 13);
- Bullet.graphics.lineTo(-5, 10);
- Bullet.graphics.lineTo(0, 0);
- break;
- }
- stage.addChild(Bullet);
- ShipClass.BulletArray.push(Bullet);
- ShipClass.BulletArray[ShipClass.BulletArray.length-1].OriginX = ShipClass.SpeedX/1.8;
- ShipClass.BulletArray[ShipClass.BulletArray.length-1].Trail = ShipClass.BulletType;
- if (ShipClass.SpeedY <= -1){
- ShipClass.BulletArray[ShipClass.BulletArray.length-1].OriginSpeed = 20;
- }else{
- ShipClass.BulletArray[ShipClass.BulletArray.length-1].OriginSpeed = 15;
- }
- if (ShipClass.BulletArray[ShipClass.BulletArray.length-1].OriginSpeed < 15){
- ShipClass.BulletArray[ShipClass.BulletArray.length-1].OriginSpeed = 15;
- }
- switch (TheBulletType){
- case "GoldBullet":
- ShipClass.BulletArray[ShipClass.BulletArray.length-1].OriginSpeed = ShipClass.BulletArray[ShipClass.BulletArray.length-1].OriginSpeed*2;
- ShipClass.BulletArray[ShipClass.BulletArray.length-1].Damage = 5;
- ShipClass.BulletArray[ShipClass.BulletArray.length-1].Rotation = 0;
- break;
- case "BlueBullet":
- ShipClass.BulletArray[ShipClass.BulletArray.length-1].OriginSpeed = ShipClass.BulletArray[ShipClass.BulletArray.length-1].OriginSpeed*2;
- ShipClass.BulletArray[ShipClass.BulletArray.length-1].Damage = 5;
- ShipClass.BulletArray[ShipClass.BulletArray.length-1].Penetrate = true;
- ShipClass.BulletArray[ShipClass.BulletArray.length-1].Rotation = 0;
- break;
- case "GreenBullet":
- ShipClass.BulletArray[ShipClass.BulletArray.length-1].OriginSpeed = ShipClass.BulletArray[ShipClass.BulletArray.length-1].OriginSpeed/2;
- ShipClass.BulletArray[ShipClass.BulletArray.length-1].Damage = 20;
- ShipClass.BulletArray[ShipClass.BulletArray.length-1].Rotation = -25;
- break;
- case "PlasmaBullet":
- ShipClass.BulletArray[ShipClass.BulletArray.length-1].OriginSpeed = ShipClass.BulletArray[ShipClass.BulletArray.length-1].OriginSpeed*2.5;
- ShipClass.BulletArray[ShipClass.BulletArray.length-1].Damage = 8;
- ShipClass.BulletArray[ShipClass.BulletArray.length-1].Rotation = 0;
- break;
- case "EvilPlasmaBullet":
- ShipClass.BulletArray[ShipClass.BulletArray.length-1].OriginSpeed = ShipClass.BulletArray[ShipClass.BulletArray.length-1].OriginSpeed*2;
- ShipClass.BulletArray[ShipClass.BulletArray.length-1].Damage = 10;
- ShipClass.BulletArray[ShipClass.BulletArray.length-1].Rotation = 0;
- break;
- case "ForkBullet":
- ShipClass.BulletArray[ShipClass.BulletArray.length-1].Damage = 6;
- ShipClass.BulletArray[ShipClass.BulletArray.length-1].Rotation = 20;
- break;
- case "RedLaser":
- ShipClass.BulletArray[ShipClass.BulletArray.length-1].Damage = 5;
- ShipClass.BulletArray[ShipClass.BulletArray.length-1].Rotation = 0;
- break;
- case "ArrowBullet":
- ShipClass.BulletArray[ShipClass.BulletArray.length-1].OriginSpeed = ShipClass.BulletArray[ShipClass.BulletArray.length-1].OriginSpeed*2;
- ShipClass.BulletArray[ShipClass.BulletArray.length-1].Damage = 8;
- ShipClass.BulletArray[ShipClass.BulletArray.length-1].Rotation = 0;
- break;
- }
- var ShiftY:uint = 0;
- switch(ShipClass.Position){
- case 40:
- ShipClass.Position = -15;
- if (Bunches >= 1){
- ShipClass.BulletArray[ShipClass.BulletArray.length-1].OriginX -= 2*Bunches;
- }
- break;
- case -15:
- ShipClass.Position = 40;
- if (Bunches >= 1){
- ShipClass.BulletArray[ShipClass.BulletArray.length-1].OriginX += 2*Bunches;
- }
- break;
- }
- Bullet.rotation += ShipClass.BulletArray[ShipClass.BulletArray.length-1].OriginX*2;
- Bullet.x = X+ShipClass.Position+(Math.floor(Math.random() * (0 - 5)) + 0)-(Math.floor(Math.random() * (0 - 5)) + 0);
- Bullet.y = Y+Math.abs(ShipClass.SpeedX)-ShiftY;
- }
- private function CreateEnemy(ThePosition:uint, X:int, Y:int, BossMode:Boolean, EnemyType:String):void{
- var Enemy:MovieClip = new MovieClip();
- Enemy.graphics.clear();
- var ListOfColours:Array = new Array("0xFF0000", "0xD700FF", "0x2E00FF", "0x00FF17",
- "0xFFFC00", "0xFF7E00");
- var EnemyColour:int = Math.floor(Math.random() * (ListOfColours.length - 0)) + 0;
- if (EnemyType == "F"){
- EnemyColour = 0;
- }
- Enemy.graphics.lineStyle(1, ListOfColours[EnemyColour]);
- var EnemyStructure:Array = new Array(0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0);
- if (WaveClass.WaveArray[WaveClass.CurrentWave-1].substring(0, 1) == "B" && BossMode){
- EnemyStructure = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
- }
- var Column:uint = 1;
- var StructureString:String = "";
- var MaxColumn:uint = 4;
- var MaxColumns:uint = 5;
- var PlaceRate:uint = 50;
- if (EnemyType == "B" && BossMode){
- MaxColumn = 16;
- MaxColumns = 20;
- PlaceRate = 80;
- }
- for (var j:uint = 0; j < EnemyStructure.length-1; j++){
- if (Column <= MaxColumn){
- var RandomCircle = (Math.floor(Math.random() * (100 - 0)) + 0);
- if (RandomCircle >= PlaceRate){
- EnemyStructure[j] = " ";
- }
- StructureString += String(EnemyStructure[j]);
- Column++;
- }else{
- Column = 1;
- for (var i:uint = 0; i < (EnemyStructure.length/MaxColumns)/2; i++){
- EnemyStructure[j+i] = String(EnemyStructure[j-i]);
- StructureString += String(EnemyStructure[j+i]);
- }
- StructureString += "\n";
- j += 3;
- }
- }
- var EnemyPoints:Array = new Array();
- Column = 1;
- var MaxRows = 8;
- if (EnemyType == "B" && BossMode){
- MaxRows = 32;
- }
- for (var c:uint = 0; c < EnemyStructure.length-1; c++){
- if (EnemyStructure[c] != " "){
- EnemyPoints.push(Column*10);
- EnemyPoints.push((Math.ceil((c+1)/MaxRows))*10);
- EnemyPoints.push(110-(Column*10));
- EnemyPoints.push((Math.ceil((c+1)/MaxRows))*10);
- }
- if (Column <= MaxRows-1){
- Column++;
- }else{
- Column = 1;
- }
- }
- for (var t:uint = 0; t < EnemyPoints.length; t += 2){
- Enemy.graphics.beginFill(ListOfColours[EnemyColour], .5);
- Enemy.graphics.moveTo(EnemyPoints[t], EnemyPoints[t+1]);
- Enemy.graphics.lineTo(EnemyPoints[t]+10, EnemyPoints[t+1]);
- Enemy.graphics.lineTo(EnemyPoints[t]+10, EnemyPoints[t+1]+10);
- Enemy.graphics.lineTo(EnemyPoints[t], EnemyPoints[t+1]+10);
- Enemy.graphics.lineTo(EnemyPoints[t], EnemyPoints[t+1]);
- Enemy.graphics.beginFill(ListOfColours[EnemyColour], 1);
- Enemy.graphics.lineTo(EnemyPoints[t]+10, EnemyPoints[t+1]);
- Enemy.graphics.lineTo(EnemyPoints[t]+10, EnemyPoints[t+1]+4);
- Enemy.graphics.lineTo(EnemyPoints[t], EnemyPoints[t+1]+4);
- Enemy.graphics.lineTo(EnemyPoints[t], EnemyPoints[t+1]);
- }
- stage.addChild(Enemy);
- EnemyClass.EnemyArray.push(Enemy);
- EnemyClass.EnemyArray[EnemyClass.EnemyArray.length-1].Speed = 5;
- EnemyClass.EnemyArray[EnemyClass.EnemyArray.length-1].Health = 5;
- EnemyClass.EnemyArray[EnemyClass.EnemyArray.length-1].Colour = ListOfColours[EnemyColour];
- EnemyClass.EnemyArray[EnemyClass.EnemyArray.length-1].Points = EnemyPoints;
- EnemyClass.EnemyArray[EnemyClass.EnemyArray.length-1].Degrees = 0;
- EnemyClass.EnemyArray[EnemyClass.EnemyArray.length-1].BulletTimer = 0;
- EnemyClass.EnemyArray[EnemyClass.EnemyArray.length-1].Rate = Math.floor(Math.random() * (120 - 50)) + 50;
- switch (EnemyClass.Sideways){
- case 5:
- EnemyClass.Sideways = -5;
- break;
- case -5:
- EnemyClass.Sideways = 5;
- break;
- }
- if (EnemyType == "D"){
- EnemyClass.EnemyArray[EnemyClass.EnemyArray.length-1].Sideways = EnemyClass.Sideways;
- EnemyClass.EnemyArray[EnemyClass.EnemyArray.length-1].Diagonal = true;
- EnemyClass.EnemyArray[EnemyClass.EnemyArray.length-1].OriginY = WaveClass.Rows;
- }else if (EnemyType == "C" || EnemyType == "S"){
- if (WaveClass.StackedNumbers >= 5){
- switch (EnemyClass.DiagonalSideways){
- case 5:
- EnemyClass.DiagonalSideways = -5;
- break;
- case -5:
- EnemyClass.DiagonalSideways = 5;
- break;
- }
- }
- EnemyClass.EnemyArray[EnemyClass.EnemyArray.length-1].Sideways = EnemyClass.DiagonalSideways;
- EnemyClass.EnemyArray[EnemyClass.EnemyArray.length-1].Spin = true;
- }
- var position:int = 0;
- if (EnemyClass.Sideways == 5){
- position = 100;
- }else{
- position = 500;
- }
- if (EnemyType == "C" && WaveClass.StackedNumbers >= 5){
- position = Math.floor(Math.random() * (300 - 0)) + 200;
- EnemyClass.EnemyArray[EnemyClass.EnemyArray.length-1].OriginX = position;
- WaveClass.StackedNumbers = 0;
- WaveClass.StoredPosition = position;
- }else{
- EnemyClass.EnemyArray[EnemyClass.EnemyArray.length-1].OriginX = WaveClass.StoredPosition;
- WaveClass.StackedNumbers++;
- }
- if (EnemyType == "B" && BossMode){
- EnemyClass.EnemyArray[EnemyClass.EnemyArray.length-1].OriginX = 350;
- EnemyClass.EnemyArray[EnemyClass.EnemyArray.length-1].BossMode = true;
- EnemyClass.EnemyArray[EnemyClass.EnemyArray.length-1].Health = 500;
- EnemyClass.EnemyArray[EnemyClass.EnemyArray.length-1].Sideways = -5;
- EnemyClass.EnemyArray[EnemyClass.EnemyArray.length-1].SpawnEnemies = 0;
- position = 350;
- }
- if (EnemyType == "F"){
- position = ThePosition;
- EnemyClass.EnemyArray[EnemyClass.EnemyArray.length-1].OriginX = position;
- EnemyClass.EnemyArray[EnemyClass.EnemyArray.length-1].Sideways = 0;
- }
- if (EnemyType == "S"){
- EnemyClass.EnemyArray[EnemyClass.EnemyArray.length-1].RestrictSpinX = true;
- }
- Enemy.x = position;
- Enemy.y = -50;
- if (X != 0){
- Enemy.x = X;
- Enemy.y = Y;
- EnemyClass.EnemyArray[EnemyClass.EnemyArray.length-1].OriginX = 0;
- EnemyClass.EnemyArray[EnemyClass.EnemyArray.length-1].OriginY = 0;
- if (EnemyType == "Mindless"){
- EnemyClass.EnemyArray[EnemyClass.EnemyArray.length-1].Mindless = true;
- }
- }
- Enemy.scaleX -= .6;
- Enemy.scaleY -= .6;
- EnemyClass.EnemiesCreated++;
- EnemyClass.EnemyArray[EnemyClass.EnemyArray.length-1].name = "Enemy" + EnemyClass.EnemiesCreated;
- }
- private function EnemyTimerComplete(Timer:TimerEvent){
- if (WaveClass.CurrentWave-1 >= WaveClass.WaveArray.length){
- EnemyClass.EnemyTimer.stop();
- EnemyClass.EndOfStageTimer.start();
- FadeMusic = true;
- MusicVolume = 1;
- }else{
- var AddZero:String = "0";
- if (WaveClass.WaveArray[WaveClass.CurrentWave-1].substring(0, 1) == "B"){
- AddZero = "";
- }
- if (EnemyClass.EnemyCounter <= int(WaveClass.WaveArray[WaveClass.CurrentWave-1].substring(1, 2) + AddZero)){
- if (WaveClass.WaveArray[WaveClass.CurrentWave-1].substring(0, 1) == "F"){
- for (var j:uint = 0; j < 8; j++){
- if (WaveClass.WaveArray[WaveClass.CurrentWave-1].substring(0, 1) == "B"){
- CreateEnemy((j*80)+50, 0, 0, true, WaveClass.WaveArray[WaveClass.CurrentWave-1].substring(0, 1));
- }else{
- CreateEnemy((j*80)+50, 0, 0, false, WaveClass.WaveArray[WaveClass.CurrentWave-1].substring(0, 1));
- }
- }
- }else{
- if (WaveClass.WaveArray[WaveClass.CurrentWave-1].substring(0, 1) == "B"){
- CreateEnemy(0, 0, 0, true, WaveClass.WaveArray[WaveClass.CurrentWave-1].substring(0, 1));
- }else{
- CreateEnemy(0, 0, 0, false, WaveClass.WaveArray[WaveClass.CurrentWave-1].substring(0, 1));
- }
- }
- EnemyClass.EnemyCounter++;
- }else if (EnemyClass.EnemyArray.length == 0 && !WaveClass.NextWaveTimer.running){
- WaveClass.NextWaveTimer.start();
- if (WaveClass.WaveArray[WaveClass.CurrentWave].substring(0, 1) == "B"){
- particleClass.CreateText(200, 200, 30, "Deltoidicus has awoken!", 0xFF0000, 80, "Nothing");
- CreateEnemyHealthBar();
- }else{
- particleClass.CreateText(200, 150, 30, "Get ready for Wave " + String(WaveClass.CurrentWave+1), 0xA10097, 80, "Nothing");
- particleClass.CreateText(200, 200, 30, WaveClass.WaveNames[WaveClass.CurrentWave], 0xFFFFFF, 50, "Nothing");
- }
- }
- EnemyClass.EnemyTimer.reset();
- EnemyClass.EnemyTimer.start();
- }
- }
- private function ShootBullet(Timer:TimerEvent){
- if (!HealthClass.Reviving && ShipClass.Shooting && !RejoinChat && !PauseGame && !SpellClass.CastSpell){
- for (var j:uint = 0; j < ShipClass.ExtraShots; j++){
- CreateBullet(j, ShipClass.Ship.x, ShipClass.Ship.y, ShipClass.BulletType);
- ConnectionClass.TheConnection.send("CreateBullet", AccountDetailsClass.Username, ShipClass.Ship.x, ShipClass.Ship.y, j, ShipClass.BulletType);
- }
- ShipClass.BulletTimer.reset();
- ShipClass.BulletTimer.start();
- }
- }
- private function NextWave(Timer:TimerEvent){
- WaveClass.NextWaveTimer.reset();
- WaveClass.NextWaveTimer.stop();
- WaveClass.CurrentWave++;
- EnemyClass.EnemyCounter = 0;
- WaveClass.RowAmount = 0;
- WaveClass.Rows = 0;
- if (WaveClass.WaveArray[WaveClass.CurrentWave-1].substring(0, 1) == "C"){
- ResetEnemyTime(400);
- }else if (WaveClass.WaveArray[WaveClass.CurrentWave-1].substring(0, 1) == "S"){
- ResetEnemyTime(100);
- }else if (WaveClass.WaveArray[WaveClass.CurrentWave-1].substring(0, 1) == "F"){
- ResetEnemyTime(2000);
- }else{
- ResetEnemyTime(200);
- }
- }
- private function ResetEnemyTime(SpawnRate:uint):void{
- var enemyTimer:Timer = new Timer(SpawnRate);
- EnemyClass.EnemyTimer.removeEventListener(TimerEvent.TIMER, EnemyTimerComplete);
- EnemyClass.EnemyTimer = enemyTimer;
- EnemyClass.EnemyTimer.addEventListener(TimerEvent.TIMER, EnemyTimerComplete);
- EnemyClass.ResetSpawnTime = true;
- EnemyClass.EnemyTimer.start();
- }
- private function ResetBulletTime(SpawnRate:uint):void{
- ShipClass.BulletTimer = new Timer(SpawnRate);
- ShipClass.BulletTimer.removeEventListener(TimerEvent.TIMER, ShootBullet);
- ShipClass.BulletTimer = ShipClass.BulletTimer;
- ShipClass.BulletTimer.addEventListener(TimerEvent.TIMER, ShootBullet);
- EnemyClass.ResetSpawnTime = true;
- ShipClass.BulletTimer.start();
- }
- private function ManageBulletLoop():void{
- for (var j:uint = 0; j < ShipClass.BulletArray.length; j++){
- ShipClass.BulletArray[j].x += ShipClass.BulletArray[j].OriginX;
- ShipClass.BulletArray[j].y -= ShipClass.BulletArray[j].OriginSpeed;
- ShipClass.BulletArray[j].rotation += ShipClass.BulletArray[j].Rotation;
- if (ShipClass.BulletArray[j].y <= -50){
- stage.removeChild(ShipClass.BulletArray[j]);
- ShipClass.BulletArray.splice(j, 1);
- }
- }
- }
- private function ManageParticleLoop():void{
- for (var l:uint = 0; l < ParticleClass.ParticleArray.length; l++){
- ParticleClass.ParticleArray[l].x += ParticleClass.ParticleArray[l].OriginX;
- ParticleClass.ParticleArray[l].y += ParticleClass.ParticleArray[l].OriginY;
- if (ParticleClass.ParticleArray[l].y <= -50){
- stage.removeChild(ParticleClass.ParticleArray[l]);
- ParticleClass.ParticleArray.splice(l, 1);
- break;
- }else if (ParticleClass.ParticleArray[l].y >= 650){
- stage.removeChild(ParticleClass.ParticleArray[l]);
- ParticleClass.ParticleArray.splice(l, 1);
- break;
- }else if (ParticleClass.ParticleArray[l].x <= 0){
- stage.removeChild(ParticleClass.ParticleArray[l]);
- ParticleClass.ParticleArray.splice(l, 1);
- break;
- }else if (ParticleClass.ParticleArray[l].x >= 850){
- stage.removeChild(ParticleClass.ParticleArray[l]);
- ParticleClass.ParticleArray.splice(l, 1);
- break;
- }
- ParticleClass.ParticleArray[l].ParticleTimer += 2;
- particleClass.CreateTrail(ParticleClass.ParticleArray[l].Colour, "Explosion", ParticleClass.ParticleArray[l].x, ParticleClass.ParticleArray[l].y);
- ParticleClass.ParticleArray[l].alpha = 1-ParticleClass.ParticleArray[l].ParticleTimer/100;
- if (ParticleClass.ParticleArray[l].ParticleTimer >= 50){
- stage.removeChild(ParticleClass.ParticleArray[l]);
- ParticleClass.ParticleArray.splice(l, 1);
- }
- }
- }
- private function ManageTrailLoop():void{
- for (var i:uint = 0; i < ParticleClass.TrailArray.length; i++){
- ParticleClass.TrailArray[i].x += (Math.floor(Math.random() * (0 - 2)) + 0)-(Math.floor(Math.random() * (0 - 2)) + 0);
- ParticleClass.TrailArray[i].y -= (Math.floor(Math.random() * (0 - 5)) + 0)-2;
- if (WaveClass.NextWaveTimer.running){
- ParticleClass.TrailArray[i].alpha -= .02;
- }else{
- ParticleClass.TrailArray[i].alpha -= .1;
- }
- if (ParticleClass.TrailArray[i].alpha <= 0){
- stage.removeChild(ParticleClass.TrailArray[i]);
- ParticleClass.TrailArray.splice(i, 1);
- }
- }
- }
- private function ManageTextLoop():void{
- for (var i:uint = 0; i < ParticleClass.TextArray.length; i += 4){
- if (ParticleClass.TextArray[i+1] >= ParticleClass.TextArray[i+2]){
- ParticleClass.TextArray[i].alpha -= .1;
- }else{
- ParticleClass.TextArray[i+1] = ParticleClass.TextArray[i+1] + 1;
- }
- if (ParticleClass.TextArray[i+3] == "Scroll"){
- ParticleClass.TextArray[i].y -= 2;
- }
- if (ParticleClass.TextArray[i].alpha <= 0){
- stage.removeChild(ParticleClass.TextArray[i]);
- ParticleClass.TextArray.splice(i, 4);
- }
- }
- }
- private function ManageStarLoop():void{
- for (var c:uint = 0; c < ParticleClass.StarsArray.length; c++){
- if (WaveClass.NextWaveTimer.running){
- ParticleClass.StarsArray[c].y += 30;
- }else{
- ParticleClass.StarsArray[c].y += 15;
- }
- if (ParticleClass.StarsArray[c].y >= 600){
- stage.removeChild(ParticleClass.StarsArray[c]);
- ParticleClass.StarsArray.splice(c, 1);
- }
- }
- }
- private function ManageUpgradesLoop():void{
- for (var c:uint = 0; c < UpgradesClass.UpgradesArray.length; c++){
- if (UpgradesClass.UpgradesArray[c].stage != null){
- UpgradesClass.UpgradesArray[c].y += 5;
- if (UpgradesClass.UpgradesArray[c].y >= 600 && !UpgradesClass.UpgradesArray[c].hitTestObject(ShipClass.Ship)){
- stage.removeChild(UpgradesClass.UpgradesArray[c]);
- UpgradesClass.UpgradesArray.splice(c, 1);
- break;
- }
- if (UpgradesClass.UpgradesArray[c].hitTestObject(ShipClass.Ship)){
- ConnectionClass.TheConnection.send("DestroyUpgrade", UpgradesClass.UpgradesArray[c].name, AccountDetailsClass.Username);
- stage.removeChild(UpgradesClass.UpgradesArray[c]);
- break;
- }
- }
- }
- }
- private function ManageGameStatements():void{
- if (WaveClass.RowAmount >= WaveClass.MaxRow){
- WaveClass.Rows += 30;
- WaveClass.RowAmount = 0;
- }
- if (HealthClass.Health <= 0 && !HealthClass.Reviving){
- HealthClass.Reviving = true;
- HealthClass.ReviveTimer.start();
- stage.removeChild(ShipClass.Ship);
- HealthClass.Health = 0;
- trace("STOPPING TIMER 1");
- ShipClass.BulletTimer.stop();
- ShipClass.Shooting = false;
- }
- }
- private function CreateHealthBar():void{
- HealthClass.HealthBar.graphics.lineStyle(1, 0xFFFFFF);
- HealthClass.HealthBar.graphics.lineTo(150, 0);
- HealthClass.HealthBar.graphics.lineTo(150, 17);
- HealthClass.HealthBar.graphics.lineTo(0, 17);
- HealthClass.HealthBar.graphics.lineTo(0, 0);
- HealthClass.HealthScroll.graphics.lineStyle(1, 0xFFFFFF);
- HealthClass.HealthScroll.graphics.beginFill(0x00FF25);
- HealthClass.HealthScroll.graphics.lineTo(140, 0);
- HealthClass.HealthScroll.graphics.lineTo(140, 7);
- HealthClass.HealthScroll.graphics.lineTo(0, 7);
- HealthClass.HealthScroll.graphics.lineTo(0, 0);
- stage.addChild(HealthClass.HealthBar);
- stage.addChild(HealthClass.HealthScroll);
- HealthClass.HealthBar.x = 5;
- HealthClass.HealthBar.y = 5;
- HealthClass.HealthScroll.x = 10;
- HealthClass.HealthScroll.y = 10;
- }
- private function CreateManaBar():void{
- HealthClass.ManaBar.graphics.lineStyle(1, 0xFFFFFF);
- HealthClass.ManaBar.graphics.lineTo(150, 0);
- HealthClass.ManaBar.graphics.lineTo(150, 17);
- HealthClass.ManaBar.graphics.lineTo(0, 17);
- HealthClass.ManaBar.graphics.lineTo(0, 0);
- HealthClass.ManaScroll.graphics.lineStyle(1, 0xFFFFFF);
- HealthClass.ManaScroll.graphics.beginFill(0x0000FF);
- HealthClass.ManaScroll.graphics.lineTo(140, 0);
- HealthClass.ManaScroll.graphics.lineTo(140, 7);
- HealthClass.ManaScroll.graphics.lineTo(0, 7);
- HealthClass.ManaScroll.graphics.lineTo(0, 0);
- stage.addChild(HealthClass.ManaBar);
- stage.addChild(HealthClass.ManaScroll);
- HealthClass.ManaBar.x = 5;
- HealthClass.ManaBar.y = 22;
- HealthClass.ManaScroll.x = 10;
- HealthClass.ManaScroll.y = 27;
- }
- public function EndThunderSpell(Event:TimerEvent){
- SpellClass.ThunderSpellTimer.reset();
- SpellClass.ThunderSpellTimer.stop();
- SpellClass.NewLine.graphics.clear();
- }
- public function EndShieldSpell(Event:TimerEvent){
- SpellClass.ShieldTimer.reset();
- SpellClass.ShieldTimer.stop();
- HealthClass.FlashTimer.stop();
- HealthClass.Invincible = false;
- ShipClass.ShipOutline = SpellClass.OriginalShipOutline;
- }
- private function CreateSpellsBox(Type:String, X:int, Y:int){
- switch(Type){
- case "ThunderArea":
- SpellClass.ThunderSpellTimer.addEventListener(TimerEvent.TIMER, EndThunderSpell);
- var TheLightningIcon:LightningIcon = new LightningIcon();
- stage.addChild(TheLightningIcon);
- TheLightningIcon.width = 60;
- TheLightningIcon.height = 40;
- TheLightningIcon.x = X;
- TheLightningIcon.y = Y;
- SpellClass.SpellsArray.push(TheLightningIcon);
- break;
- case "HolyShield":
- SpellClass.ShieldTimer.addEventListener(TimerEvent.TIMER, EndShieldSpell);
- var TheShieldIcon:ShieldIcon = new ShieldIcon();
- stage.addChild(TheShieldIcon);
- TheShieldIcon.width = 60;
- TheShieldIcon.height = 40;
- TheShieldIcon.x = X;
- TheShieldIcon.y = Y;
- SpellClass.SpellsArray.push(TheShieldIcon);
- break;
- case "Heal":
- var TheHealIcon:HealIcon = new HealIcon();
- stage.addChild(TheHealIcon);
- TheHealIcon.width = 60;
- TheHealIcon.height = 40;
- TheHealIcon.x = X;
- TheHealIcon.y = Y;
- SpellClass.SpellsArray.push(TheHealIcon);
- break;
- }
- SpellClass.SpellsArray[SpellClass.SpellsArray.length-1].Type = Type;
- }
- private function ReviveShip(Timer:TimerEvent){
- if (!HealthClass.Invincible){
- DrawShip();
- HealthClass.ReviveTimer.reset();
- HealthClass.ReviveTimer.start();
- HealthClass.Reviving = false;
- HealthClass.Health = HealthClass.MaxHealth;
- HealthClass.Invincible = true;
- HealthClass.FlashTimer.start();
- }else{
- HealthClass.Invincible = false;
- HealthClass.ReviveTimer.stop();
- HealthClass.FlashTimer.stop();
- ShipClass.Ship.alpha = 1;
- HealthClass.Reviving = false;
- }
- }
- private function FlashTimerComplete(Timer:TimerEvent){
- HealthClass.FlashTimer.reset();
- HealthClass.FlashTimer.start();
- if (HealthClass.Flashing){
- HealthClass.Flashing = false;
- ShipClass.Ship.alpha = 1;
- }else{
- HealthClass.Flashing = true;
- ShipClass.Ship.alpha = .1;
- }
- }
- private function CreateEnemyHealthBar():void{
- EnemyClass.EnemyHealthBar.graphics.lineStyle(1, 0xFFFFFF);
- EnemyClass.EnemyHealthBar.graphics.lineTo(150, 0);
- EnemyClass.EnemyHealthBar.graphics.lineTo(150, 25);
- EnemyClass.EnemyHealthBar.graphics.lineTo(0, 25);
- EnemyClass.EnemyHealthBar.graphics.lineTo(0, 0);
- EnemyClass.EnemyHealthScroll.graphics.lineStyle(1, 0xFFFFFF);
- EnemyClass.EnemyHealthScroll.graphics.beginFill(0xFF0000);
- EnemyClass.EnemyHealthScroll.graphics.lineTo(140, 0);
- EnemyClass.EnemyHealthScroll.graphics.lineTo(140, 15);
- EnemyClass.EnemyHealthScroll.graphics.lineTo(0, 15);
- EnemyClass.EnemyHealthScroll.graphics.lineTo(0, 0);
- stage.addChild(EnemyClass.EnemyHealthBar);
- stage.addChild(EnemyClass.EnemyHealthScroll);
- EnemyClass.EnemyHealthBar.x = 680;
- EnemyClass.EnemyHealthBar.y = 5;
- EnemyClass.EnemyHealthScroll.x = 690;
- EnemyClass.EnemyHealthScroll.y = 10;
- }
- private function SendMovementConnections(Timer:TimerEvent){
- ShipClass.MovementTimer.reset();
- ShipClass.MovementTimer.start();
- ConnectionClass.TheConnection.send("SendMovements", AccountDetailsClass.Username, ShipClass.Ship.x, ShipClass.Ship.y, stage.mouseX);
- }
- private function MovePlayerShip(ShipNumber:int, speedx:int):void{
- var distanceX:Number = 0;
- ShipClass.ShipArray[ShipNumber].graphics.clear();
- ShipClass.ShipArray[ShipNumber].graphics.lineStyle(2, ShipClass.ShipArray[ShipNumber].Outline);
- ShipClass.ShipArray[ShipNumber].graphics.beginFill(ShipClass.ShipArray[ShipNumber].Fill, 1-Math.abs(distanceX)/40);
- if (speedx <= ShipClass.ShipArray[ShipNumber].x){
- //Creating the basic shape of the ship
- ShipClass.ShipArray[ShipNumber].graphics.lineTo(25-distanceX, 0-distanceX);
- ShipClass.ShipArray[ShipNumber].graphics.lineTo(55-distanceX, 25-distanceX);
- ShipClass.ShipArray[ShipNumber].graphics.lineTo(-25+distanceX, 25+distanceX);
- ShipClass.ShipArray[ShipNumber].graphics.lineTo(0, 0);
- //Creating shading to the back of the ship
- ShipClass.ShipArray[ShipNumber].graphics.beginFill(ShipClass.ShipArray[ShipNumber].DarkOutline, .8);
- ShipClass.ShipArray[ShipNumber].graphics.lineStyle(1, ShipClass.ShipArray[ShipNumber].DarkOutline, .8);
- ShipClass.ShipArray[ShipNumber].graphics.moveTo(-20+distanceX, 20+distanceX);
- ShipClass.ShipArray[ShipNumber].graphics.lineTo(50-distanceX, 20-distanceX);
- ShipClass.ShipArray[ShipNumber].graphics.lineTo(55-distanceX, 25-distanceX);
- ShipClass.ShipArray[ShipNumber].graphics.lineTo(-25+distanceX, 25+distanceX);
- //Creating Back model of the ship
- ShipClass.ShipArray[ShipNumber].graphics.beginFill(ShipClass.ShipArray[ShipNumber].BackColour, 1-Math.abs(distanceX)/40);
- ShipClass.ShipArray[ShipNumber].graphics.lineStyle(1, ShipClass.ShipArray[ShipNumber].Outline, .8);
- ShipClass.ShipArray[ShipNumber].graphics.moveTo(55-distanceX, 25-distanceX);
- ShipClass.ShipArray[ShipNumber].graphics.lineTo(55-distanceX, 32-distanceX);
- ShipClass.ShipArray[ShipNumber].graphics.lineTo(-25+distanceX, 32+distanceX);
- ShipClass.ShipArray[ShipNumber].graphics.lineTo(-25+distanceX, 25+distanceX);
- //Creating the right missle on the ship
- ShipClass.ShipArray[ShipNumber].graphics.beginFill(ShipClass.ShipArray[ShipNumber].Fill, .8);
- ShipClass.ShipArray[ShipNumber].graphics.lineStyle(1, ShipClass.ShipArray[ShipNumber].Outline, 1-distanceX/40);
- ShipClass.ShipArray[ShipNumber].graphics.moveTo(33-distanceX, 5-distanceX);
- ShipClass.ShipArray[ShipNumber].graphics.lineTo(50-distanceX, 5-distanceX);
- ShipClass.ShipArray[ShipNumber].graphics.lineTo(55-distanceX, 25-distanceX);
- ShipClass.ShipArray[ShipNumber].graphics.lineTo(33-distanceX, 5-distanceX);
- //Creating the left missle on the ship
- ShipClass.ShipArray[ShipNumber].graphics.beginFill(ShipClass.ShipArray[ShipNumber].Fill, 1-distanceX/25);
- ShipClass.ShipArray[ShipNumber].graphics.lineStyle(1, ShipClass.ShipArray[ShipNumber].Outline, 1-distanceX/25);
- ShipClass.ShipArray[ShipNumber].graphics.moveTo(-4, 5);
- ShipClass.ShipArray[ShipNumber].graphics.lineTo(-21+distanceX, 5+distanceX);
- ShipClass.ShipArray[ShipNumber].graphics.lineTo(-26+distanceX, 25+distanceX);
- ShipClass.ShipArray[ShipNumber].graphics.lineTo(-4, 5);
- }else{
- distanceX = distanceX/1.8;
- //Creating the left missle on the ship
- ShipClass.ShipArray[ShipNumber].graphics.beginFill(ShipClass.ShipArray[ShipNumber].Fill, 1-Math.abs(distanceX)/40);
- ShipClass.ShipArray[ShipNumber].graphics.lineStyle(1, ShipClass.ShipArray[ShipNumber].Outline, .8);
- ShipClass.ShipArray[ShipNumber].graphics.moveTo(-4+distanceX, 5-distanceX/2);
- ShipClass.ShipArray[ShipNumber].graphics.lineTo(-21+distanceX, 5-distanceX/2);
- ShipClass.ShipArray[ShipNumber].graphics.lineTo(-26+distanceX, 25-distanceX/2);
- ShipClass.ShipArray[ShipNumber].graphics.lineTo(-4+distanceX, 5-distanceX/2);
- //Creating the basic shape of the ship
- ShipClass.ShipArray[ShipNumber].graphics.lineStyle(2, ShipClass.ShipArray[ShipNumber].Outline);
- ShipClass.ShipArray[ShipNumber].graphics.beginFill(ShipClass.ShipArray[ShipNumber].Fill, 1-distanceX/40);
- ShipClass.ShipArray[ShipNumber].graphics.moveTo(0, 0);
- ShipClass.ShipArray[ShipNumber].graphics.lineTo(25-distanceX, 0+distanceX);
- ShipClass.ShipArray[ShipNumber].graphics.lineTo(55-distanceX, 25+distanceX);
- ShipClass.ShipArray[ShipNumber].graphics.lineTo(-25+distanceX, 25-distanceX);
- ShipClass.ShipArray[ShipNumber].graphics.lineTo(0, 0);
- //Creating shading to the back of the ship
- ShipClass.ShipArray[ShipNumber].graphics.beginFill(ShipClass.ShipArray[ShipNumber].DarkOutline, .8);
- ShipClass.ShipArray[ShipNumber].graphics.lineStyle(1, ShipClass.ShipArray[ShipNumber].DarkOutline, .8);
- ShipClass.ShipArray[ShipNumber].graphics.moveTo(-20+distanceX, 20-distanceX);
- ShipClass.ShipArray[ShipNumber].graphics.lineTo(50-distanceX, 20+distanceX);
- ShipClass.ShipArray[ShipNumber].graphics.lineTo(55-distanceX, 25+distanceX);
- ShipClass.ShipArray[ShipNumber].graphics.lineTo(-25+distanceX, 25-distanceX);
- //Creating Back model of the ship
- ShipClass.ShipArray[ShipNumber].graphics.beginFill(ShipClass.ShipArray[ShipNumber].BackColour, 1-distanceX/40);
- ShipClass.ShipArray[ShipNumber].graphics.lineStyle(1, ShipClass.ShipArray[ShipNumber].Outline, .8);
- ShipClass.ShipArray[ShipNumber].graphics.moveTo(55-distanceX, 25+distanceX);
- ShipClass.ShipArray[ShipNumber].graphics.lineTo(55-distanceX, 32+distanceX);
- ShipClass.ShipArray[ShipNumber].graphics.lineTo(-25+distanceX, 32-distanceX);
- ShipClass.ShipArray[ShipNumber].graphics.lineTo(-25+distanceX, 25-distanceX);
- //Creating the right missle on the ship
- ShipClass.ShipArray[ShipNumber].graphics.beginFill(ShipClass.ShipArray[ShipNumber].Fill, 1-distanceX/50);
- ShipClass.ShipArray[ShipNumber].graphics.lineStyle(1, ShipClass.ShipArray[ShipNumber].Outline, 1-distanceX/50);
- ShipClass.ShipArray[ShipNumber].graphics.moveTo(33-distanceX, 5+distanceX);
- ShipClass.ShipArray[ShipNumber].graphics.lineTo(50-distanceX, 5+(distanceX*2));
- ShipClass.ShipArray[ShipNumber].graphics.lineTo(55-distanceX, 25+distanceX);
- ShipClass.ShipArray[ShipNumber].graphics.lineTo(33-distanceX, 5+distanceX);
- }
- ShipClass.ShipArray[ShipNumber].scaleX = .7;
- ShipClass.ShipArray[ShipNumber].scaleY = .7;
- }
- private function CreateMoneyText():void{
- stage.addChild(MoneyDisplay);
- MoneyDisplay.embedFonts = true;
- var NameProperties:TextFormat = new TextFormat();
- NameProperties.font = myFont.fontName;
- MoneyDisplay.defaultTextFormat = NameProperties;
- MoneyDisplay.x = 760;
- MoneyDisplay.y = 30;
- MoneyDisplay.width = 500;
- MoneyDisplay.height = 25;
- MoneyDisplay.selectable = false;
- MoneyDisplay.text = String(AccountDetailsClass.Money);
- MoneyDisplay.textColor = 0xFFD200;
- }
- }
- }
Add Comment
Please, Sign In to add comment