public void SetSource(NetworkFighterScript _source) { _source.MyArrow = gameObject; amServer = _source.isServer; source = _source; GetComponent <BoxCollider2D>().enabled = true; }
// Use this for initialization void Start() { //Setting variables localPlayer = GetComponent <NetworkFighterScript>(); //set current percentage to the starting percentage amount currentPercentage = startingPercentage; rigid = GetComponent <Rigidbody2D>(); }
public void Initialize() { if (initialized) { return; } keyList = new int[7] { 10, 11, 12, 13, 14, 15, 16 }; database = new Dictionary <int, System.Action> { { 10, TakeDamage }, { 11, SpeedBoost }, { 12, HealSelf }, { 13, Teleport }, { 14, TakeBigDamage }, { 15, Arrow }, { 16, GravityIncrease } }; cardNames = new Dictionary <int, string> { { 10, "Damage 10" }, { 11, "Speed Up" }, { 12, "Heal Up" }, { 13, "Teleport" }, { 14, "Damage 25" }, { 15, "Arrow" }, { 16, "Gravity Increase" } }; cardTexts = new Dictionary <int, string> { { 10, "Opponent takes 10 damage." }, { 11, "Your speed increases slightly." }, { 12, "You heal for up to 10 damage." }, { 13, "You can teleport in any direction you point towards." }, { 14, "Opponent takes 25 damage." }, { 15, "You shoot an arrow." }, { 16, "Your opponent's gravity is now higher." } }; manaCosts = new Dictionary <int, string> { { 10, "1" }, { 11, "2" }, { 12, "2" }, { 13, "2" }, { 14, "2" }, { 15, "1" }, { 16, "1" } }; source = GameObject.Find("Main Character (Network)(Clone)").GetComponent <NetworkFighterScript>(); health = GameObject.Find("Main Character (Network)(Clone)").GetComponent <FighterHealthScript>(); initialized = true; }
public void SetSources(GameObject player) { source = player.GetComponent <NetworkFighterScript>(); health = player.GetComponent <FighterHealthScript>(); }
// Update is called once per frame void FixedUpdate() { //print(Time.timeSinceLevelLoad.ToString() + " - " + playerState); //if (!matchStarted) //{ // transform.position = new Vector3(0, 0, transform.position.z); // if (Input.GetKeyDown(KeyCode.Space)) // { // readied = !readied; // } // if (readied) // { // endGameText.GetComponent<Text>().text = "Ready\nPress spacebar to not be ready"; // if (opponent && opponent.GetComponent<NetworkFighterScript>().Ready && isServer) // { // networkManager.GetComponent<NetworkSpawnHandler>().CmdStartMatch(); // } // } // else // { // endGameText.GetComponent<Text>().text = "Not Ready\nPress spacebar to be ready"; // } // return; //} //run all usual code if the player hasn't won or lost yet if (playerState == 0) { endGameText.GetComponent <Text>().text = ""; gameObject.SetActive(true); if (!isLocalPlayer) { return; } networkManager.GetComponent <CardEffects>().SetSources(gameObject); //SetCamera(); DisplayHealth(); if (opponent == null) { GameObject[] players = GameObject.FindGameObjectsWithTag("Player"); foreach (GameObject player in players) { if (player != this.gameObject) { opponent = player; } } } //takes in "Horizontal" input for movement on the X-Axis (Refer to the Project-> Project Settings -> Input) float inputX = Input.GetAxis("Horizontal"); //Flips the direction the character is facing Flip(inputX); CmdFlip(inputX); CorrectFlip(); anim.SetFloat("Speed", Mathf.Abs(rigid.velocity.x)); //Moves the character each frame if (inputX != 0) { Move(inputX); } //Checks if the character is within the boundaries of the stage CheckBoundaries(); //Checks for jump CheckJump(); //Checks player state CheckPlayerState(); CheckInput(); ManaSystem(); if (!gameStarted && Opponent && lives == 4 && endGameText.GetComponent <Text>().text == "") { gameStarted = true; } if (Opponent) { #region EnemyTelegraphSetup o_NetFighterScript = opponent.GetComponent <NetworkFighterScript>(); float opponentTimer = o_NetFighterScript.TimeStopTimer; if (opponentTimeStopTimer <= 0 && opponentTimer > opponentTimeStopTimer) { opponentTimeStopTimer = opponentTimer; } if (opponentTimeStopTimer > 0) { telegraph2.GetComponent <Image>().sprite = networkManager.GetComponent <CardSelect>().cardArt[o_NetFighterScript.ArtArrayNum]; telegraph2.enabled = true; } else { telegraph2.enabled = false; } #endregion if (timeStopTimer <= 0) { telegraph1.enabled = false; } if (telegraph1.enabled || telegraph2.enabled) { //Time.timeScale = cardTimeScale; // telegraph time slow code here, Dito } else { //Time.timeScale = defaultTime; // disable telegraph time slow code here, Dito } float nextTimeStopTimer = timeStopTimer - Time.deltaTime; CmdSetStopTimer(nextTimeStopTimer); timeStopTimer = nextTimeStopTimer; opponentTimeStopTimer -= Time.deltaTime; int dmg = o_NetFighterScript.OpponentDamage - lastDamage; if (dmg > 0) { localPlayerHealthScript.CmdTakeDamage(dmg); lastDamage += dmg; } //float myOppGravTimer = Opponent.GetComponent<NetworkFighterScript>().OpponentGravTimer; //print("oppgravtime: " + myOppGravTimer); //if (myOppGravTimer > totalGravTimer) //{ // print("triggered grav start"); // gravTimer = myOppGravTimer - totalGravTimer; // totalGravTimer = myOppGravTimer; //} //if (gravTimer > 0) //{ // print("grav increased"); // GetComponent<Rigidbody2D>().gravityScale = gravityScale; // gravTimer -= Time.deltaTime; // if (gravTimer <= 0) // { // GetComponent<Rigidbody2D>().gravityScale = baseGravScale; // } //} } } //run this code if the player has won if (gameStarted && playerState == 1) { endGameText.SetActive(true); endGameText.GetComponent <Text>().text = "You Win!\nPress Any Button to Exit"; if (Input.anyKey) { Debug.Break(); Application.Quit(); } } //run this code if the player has lost if (gameStarted && playerState == 2) { endGameText.SetActive(true); endGameText.GetComponent <Text>().text = "You Lose...\nPress Any Button to Exit"; Reset(); rigid.bodyType = RigidbodyType2D.Static; if (Input.anyKey) { Debug.Break(); Application.Quit(); } } }