Esempio n. 1
0
 void Awake()
 {
     Client.GameStarted += StartGame;
     CurrentMenu         = StartScreen.Instance();
     CurrentContextMenu  = EmptyContextMenu.Instance();
     State          = GameState.START_SCREEN;
     MaximumPlayers = StartPoints.Count;
     FieldWidth     = fieldwidth;
     FieldHeight    = fieldheight;
     GroundWidth    = groundwidth;
     GroundHeight   = groundheight;
     Players        = players;
     Field.Width    = FieldWidth;
     Field.Height   = FieldHeight;
     Ground.Width   = GroundWidth;
     Ground.Height  = GroundHeight;
     StartPoints.Add(new Point(0 - (Ground.Width / 2), 0 - (Ground.Height / 2)));
     StartPoints.Add(new Point(0 - (Ground.Width / 2), (Ground.Height / 2) - 1));
     StartPoints.Add(new Point(Ground.Width / 2, Ground.Height / 2));
     StartPoints.Add(new Point(Ground.Width / 2, 0 - ((Ground.Height / 2) - 1)));
     Rectangles.Add(new Rect(0 - Ground.Width / 2, 0 - Ground.Height / 2, Ground.Width, Ground.Height));
     Rectangles.Add(new Rect(0 - Field.Width / 2, 0 - Field.Height / 2, Field.Width, Field.Height));
     SpellList.Add(Fireball.Instance());
     SpellList.Add(Blink.Instance());
 }
Esempio n. 2
0
    public override void Show()
    {
        GUIStyle spellButton = new GUIStyle();

        spellButton.fontSize         = 17;
        spellButton.alignment        = TextAnchor.UpperCenter;
        spellButton.normal.textColor = Color.black;

        width      = 75;
        height     = 75;
        offset     = 15;
        textOffset = 12.5f;

        ShowButton(new Rect(offset, Screen.height - height, width, height), GameResources.Fireball, Fireball.Instance().Cooldown, Fireball.Instance().CooldownTimeElapsed, null, spellButton);
        ShowButton(new Rect(offset * 2 + width, Screen.height - height, width, height), GameResources.Blink, Blink.Instance().Cooldown, Blink.Instance().CooldownTimeElapsed, null, spellButton);
        ShowPreview("Character 1");
    }
Esempio n. 3
0
 public void FillStats()
 {
     Fireball.Instance().SetValues();
     Blink.Instance().SetValues();
 }
Esempio n. 4
0
 void FixedUpdate()
 {
     if (Game.State == GameState.GAME)
     {
         if (CurrentTime <= CastingTime)
         {
             CurrentTime += Time.deltaTime;
         }
         else
         {
             IsCasting   = false;
             CurrentTime = 0;
         }
         Ray          ray = Camera.main.ScreenPointToRay(Input.mousePosition);
         RaycastHit2D hit = Physics2D.Raycast(ray.origin, ray.direction, 200);
         if (hit)
         {
             MousePosition = new Vector3(hit.point.x, hit.point.y);
         }
         if (!Game.Rectangles[0].Contains(transform.position))
         {
             Hp -= Time.deltaTime * 10;
         }
         for (int i = 0; i < Game.SpellList.Count; i++)
         {
             if (Game.SpellList[i].CooldownTimeElapsed < Game.SpellList[i].Cooldown)
             {
                 Game.SpellList[i].CooldownTimeElapsed += Time.deltaTime;
             }
         }
         if (Hp <= 0)
         {
             Game.PlayerList.Remove(this);
             GameObject.Destroy(this.transform.gameObject);
         }
         if (IsControllable)
         {
             float x      = 0;
             float y      = 0;
             bool  change = false;
             if (Input.GetKey(KeyCode.A))
             {
                 x     -= Speed;
                 change = true;
             }
             if (Input.GetKey(KeyCode.D))
             {
                 x     += Speed;
                 change = true;
             }
             if (Input.GetKey(KeyCode.W))
             {
                 y     += Speed;
                 change = true;
             }
             if (Input.GetKey(KeyCode.S))
             {
                 y     -= Speed;
                 change = true;
             }
             Direction = new Vector2(x, y);
             if (change)
             {
                 this.rigidbody2D.velocity = Direction;
                 Client.Send(Message.GetBytes(new Message(MESSAGE_TYPE.REQUEST_MOVE, Client.login, new object[] { Direction.x, Direction.y })));
             }
             else
             {
                 this.rigidbody2D.velocity = new Vector2(0, 0);
             }
             if (Input.GetKey(KeyCode.Z))
             {
                 CurrentSpell = Fireball.Instance();
                 if (CurrentSpell.CooldownTimeElapsed >= CurrentSpell.Cooldown)
                 {
                     Invoke("SpellCallback", CurrentSpell.Casttime);
                     IsControllable            = false;
                     IsCasting                 = true;
                     CurrentTime               = 0;
                     CastingTime               = CurrentSpell.Casttime;
                     this.rigidbody2D.velocity = new Vector2(0, 0);
                 }
                 else
                 {
                     CurrentSpell = null;
                 }
             }
             if (Input.GetKey(KeyCode.X))
             {
                 CurrentSpell = Blink.Instance();
                 if (CurrentSpell.CooldownTimeElapsed >= CurrentSpell.Cooldown)
                 {
                     Invoke("SpellCallback", CurrentSpell.Casttime);
                     this.rigidbody2D.velocity = new Vector2(0, 0);
                 }
                 else
                 {
                     CurrentSpell = null;
                 }
             }
         }
     }
 }