Exemple #1
0
    void Update()
    {
        //アニメーション
        _tAnim++;
        if (_tAnim % 32 < 16)
        {
            SetSprite(spr0);
        }
        else
        {
            SetSprite(spr1);
        }

        // インターバルタイマー更新 (※①)
        _tFirerate += Time.deltaTime;

        // 一番近い敵を求める(④)
        Enemy e = Enemy.parent.Nearest(this);

        if (e == null)
        {
            // 敵がいないので何もしない
            return;
        }
        // 敵への距離を取得する(⑤)
        float dist = Util.DistanceBetween(this, e);
        float targetAngle;

        // 敵への角度を取得(⑥)
        targetAngle = Util.AngleBetween(this, e);


        if (dist > _range)
        {
            // 射程範囲外
            return;
        }


        // 現在向いている角度との差を求める
        float dAngle = Mathf.DeltaAngle(Angle, targetAngle);

        // インターバルチェック (※②)
        if (_tFirerate < _firerate)
        {
            // インターバル中
            return;
        }

        // ショットを撃つ
        Shot.Add(X, Y, targetAngle, SHOT_SPEED, _power);

        // インターバルを入れる
        _tFirerate = 0;
    }
Exemple #2
0
        /// <summary>
        /// Generates a match object from its XML representation.
        /// </summary>
        /// <param name="reader"></param>
        public void ReadXml(System.Xml.XmlReader reader)
        {
            if (reader.Name != "Point")
            {
                throw new Exception("Unexpected node encountered, Point expected");
            }

            String _ID         = reader.GetAttribute("ID");
            String _Winner     = reader.GetAttribute("Winner");
            String _Server     = reader.GetAttribute("Server");
            String _Serve      = reader.GetAttribute("Serve");
            String _ResultType = reader.GetAttribute("ResultType");
            String _Error      = reader.GetAttribute("Error");
            String _Ace        = reader.GetAttribute("Ace");

            ID         = long.Parse(_ID);
            Winner     = int.Parse(_Winner);
            Server     = int.Parse(_Server);
            Serve      = (PointServe)System.Enum.Parse(typeof(PointServe), _Serve);
            ResultType = (PointResultType)System.Enum.Parse(typeof(PointResultType), _ResultType);
            Error      = (PointError)System.Enum.Parse(typeof(PointError), _Error);
            Ace        = (PointAce)System.Enum.Parse(typeof(PointAce), _Ace);

            //Process Shots and Types
            while (!(reader.Name == "Point" && reader.NodeType == System.Xml.XmlNodeType.EndElement) && reader.Read())
            {
                if (reader.NodeType == System.Xml.XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                    case "Shot":

                        while (reader.Name == "Shot")
                        {
                            String _Shot = reader.ReadElementContentAsString();
                            Shot.Add((PointShot)System.Enum.Parse(typeof(PointShot), _Shot));
                        }

                        break;


                    case "Type":

                        while (reader.Name == "Type")
                        {
                            String _Type = reader.ReadElementContentAsString();
                            Type.Add((PointType)System.Enum.Parse(typeof(PointType), _Type));
                        }

                        break;
                    }
                }
            }
        }
Exemple #3
0
    void Update()
    {
        // インターバルタイマー更新 (※①)
        _tFirerate += Time.deltaTime;

        // 一番近い敵を求める(④)
        Enemy e = Enemy.parent.Nearest(this);

        if (e == null)
        {
            // 敵がいないので何もしない
            return;
        }
        // 敵への距離を取得する(⑤)
        float dist = Util.DistanceBetween(this, e);

        if (dist > _range)
        {
            // 射程範囲外
            return;
        }

        // 敵への角度を取得(⑥)
        float targetAngle = Util.AngleBetween(this, e);
        // 現在向いている角度との差を求める
        float dAngle = Mathf.DeltaAngle(Angle, targetAngle);

        // 差の0.2だけ回転する
        Angle += dAngle * 0.2f;
        // もう一度角度差を求める(⑦)
        float dAngle2 = Mathf.DeltaAngle(Angle, targetAngle);

        if (Mathf.Abs(dAngle2) > 16)
        {
            // 角度が大きい(16度より大きい)場合は撃てない
            return;
        }

        // インターバルチェック (※②)
        if (_tFirerate < _firerate)
        {
            // インターバル中
            return;
        }

        // ショットを撃つ
        Shot.Add(X, Y, Angle, SHOT_SPEED, _power);

        // インターバルを入れる
        _tFirerate = 0;
    }
Exemple #4
0
    // Update is called once per frame
    void Update()
    {
        Vector2 v     = Util.GetInputVector();
        float   speed = MoveSpeed * Time.deltaTime;

        ClampScreenAndMove(v * speed);

        if (Input.GetKey(KeyCode.Z))
        {
            float py  = Y + Random.Range(0, SpriteHeight / 2);
            float dir = Random.Range(-3.0f, 3.0f);
            Shot.Add(X, py, dir, 10);
        }
    }
Exemple #5
0
    // Update is called once per frame
    void Update()
    {
        // インターバルタイマー更新
        _tFirerate += Time.deltaTime;

        // 一番近い敵を求める
        Enemy e = Enemy.parent.Nearest(this);

        if (e == null)
        {
            // 敵がいない場合は何もしない
            return;
        }

        // 敵への距離を取得する
        float dist = Util.DistanceBetween(this, e);

        if (dist > _range)
        {
            // 射程範囲外なので何もしない
            return;
        }

        // 敵への角度を取得
        float targetAngle = Util.AngleBetween(this, e);
        float dAngle      = Mathf.DeltaAngle(Angle, targetAngle);

        // 差の0.2だけ回転する
        Angle += dAngle * 0.2f;
        // もう一度角度差を求める
        float dAngle2 = Mathf.DeltaAngle(Angle, targetAngle);

        if (Mathf.Abs(dAngle2) > 16)
        {
            // 角度が大きい場合は撃たない
            return;
        }

        // インターバルチェック
        if (_tFirerate < _firerate)
        {
            // インターバル中(連射抑制)
            return;
        }

        // ショットを撃つ
        Shot.Add(X, Y, Angle, SHOT_SPEED, _power);
        _tFirerate = 0;
    }
Exemple #6
0
    // Update is called once per frame
    void Update()
    {
        //インターバルタイマー更新
        _tFirerate += Time.deltaTime;
        Enemy e = Enemy.parent.Nearest(this);

        if (e == null)
        {
            //敵がいないので何にしない
            return;
        }
        //敵への距離を取得する
        float dist = Util.DistanceBetween(this, e);

        if (dist > _range)
        {
            //射程範囲外
            return;
        }
        //敵への角度を取得
        float targetAngle = Util.AngleBetween(this, e);
        //現在向いている角度との差を求める
        float dAngle = Mathf.DeltaAngle(Angle, targetAngle);

        //差の0.2だけ回転する。
        Angle += dAngle * 0.2f;
        //もう一度角度差を求める
        float dAngle2 = Mathf.DeltaAngle(Angle, targetAngle);

        if (Mathf.Abs(dAngle2) > 16)
        {
            //角度が大きい場合は撃てない
            return;
        }

        if (_tFirerate < _firerate)
        {
            return;
        }


        //ショットを撃つ
        Shot.Add(X, Y, Angle, SHOT_SPEED, _power);
        audioClip1.PlayOneShot(audioClip1.clip);          //


        _tFirerate = 0;
    }
Exemple #7
0
        /// <summary>
        /// Process the Ace command
        /// </summary>
        public void CommandAce()
        {
            ResultType = PointResultType.Winner;
            Shot.Add(PointShot.Ace);

            if (PartOf == null)
            {
                throw new Exception("No reference to a game available. Unable to determine winner.");
            }

            if (PartOf.Server == GetLocalPlayer())
            {
                CommandWin();
            }
            else
            {
                CommandLose();
            }
        }
Exemple #8
0
    /// 更新
    void Update()
    {
        // 移動処理
        Vector2 v     = Util.GetInputVector();
        float   speed = MoveSpeed * Time.deltaTime;

        // 移動して画面外に出ないようにする
        ClampScreenAndMove(v * speed);

        // Spaceキーでショットを撃つ
        if (Input.GetKey(KeyCode.Space))
        {
            // X座標をランダムでずらす
            float px = X + Random.Range(0, SpriteWidth / 2);
            // 発射角度を±3する
            float dir = Random.Range(-3.0f, 3.0f);
            Shot.Add(px, Y, dir, 10);
        }
    }
Exemple #9
0
 /// <summary>
 /// Process the smash command
 /// </summary>
 public void CommandSmash()
 {
     Shot.Add(PointShot.OverheadShot);
 }
Exemple #10
0
 /// <summary>
 /// Process the passing command
 /// </summary>
 public void CommandPassing()
 {
     Shot.Add(PointShot.Passing);
 }
Exemple #11
0
 /// <summary>
 /// Process the volley command
 /// </summary>
 public void CommandVolley()
 {
     Shot.Add(PointShot.Volley);
 }
Exemple #12
0
 /// <summary>
 /// Process the lob command
 /// </summary>
 public void CommandLob()
 {
     Shot.Add(PointShot.Lob);
 }
Exemple #13
0
 /// <summary>
 /// Process the dropshot command
 /// </summary>
 public void CommandDropshot()
 {
     Shot.Add(PointShot.Dropshot);
 }
Exemple #14
0
 /// <summary>
 /// Process the backhand command
 /// </summary>
 public void CommandBackhand()
 {
     Shot.Add(PointShot.Backhand);
     Shot.Add(PointShot.GroundStroke);
 }
Exemple #15
0
 /// <summary>
 /// Process the forehand command
 /// </summary>
 public void CommandForehand()
 {
     Shot.Add(PointShot.Forehand);
     Shot.Add(PointShot.GroundStroke);
 }