Inheritance: MonoBehaviour
Exemple #1
0
        public void WriteTest() => File.OpenRead(FileName).Using(x => Helpers.AssertStream(x, stream =>
        {
            var outStream = new MemoryStream();
            ObjectCollision.Write(outStream, ObjectCollision.Read(stream));

            return(outStream);
        }));
Exemple #2
0
 void Start()
 {
     rb   = GetComponent <Rigidbody2D>();
     sr   = GetComponent <SpriteRenderer>();
     anim = GetComponent <Animator>();
     oc   = GetComponent <ObjectCollision>();
     col  = GetComponent <BoxCollider2D>();
 }
Exemple #3
0
    void OnCollisionEnter(Collision collision)
    {
        ObjectCollision other = collision.gameObject.GetComponent <ObjectCollision>();

        if (other != null && other._toughness >= _toughness)
        {
            // StartCoroutine(SmashThis());
        }
    }
Exemple #4
0
 // Start is called before the first frame update
 void Start()
 {
     rb       = GetComponent <Rigidbody2D>();
     sr       = GetComponent <SpriteRenderer>();
     animator = GetComponent <Animator>();
     oc       = GetComponent <ObjectCollision>();
     bcol     = GetComponent <BoxCollider2D>();
     gm       = GManager.GetInstance();
 }
Exemple #5
0
        public GameObject(Type gameType)
        {
            ObjType = gameType;
            item    = new TextureItem((System.Drawing.Bitmap)GameCore.CoreFiles.getTexture(ObjType).Clone(), gameType);
            switch (ObjType)
            {
            case Type.Barn:
                Health     = 100;
                Population = 3;
                break;

            case Type.House:
                Health     = 200;
                Population = 5;
                break;

            case Type.Outhouse:
                Health     = 300;
                Population = 10;
                break;

            case Type.BigBarn:
                Health     = 400;
                Population = 30;
                break;

            case Type.Shop:
                Health     = 250;
                Population = 10;
                break;

            case Type.Hay:
                Health = 50;
                Feeds  = 10;
                break;

            case Type.Windmil:
                Health     = 100;
                Population = 3;
                break;

            case Type.Footman:
                Health     = 250;
                Damage     = 1;
                RequiredXP = 100;
                Population = 1;
                Moveable   = true;
                break;

            case Type.Grass:
                break;
            }
            MaxHealth    = Health;
            Health      -= 20;
            OnCollision += new ObjectCollision(GameObject_OnCollision);
        }
Exemple #6
0
 void Start()
 {
     oc   = GetComponent <ObjectCollision>();
     anim = GetComponent <Animator>();
     if (oc == null || anim == null)
     {
         Debug.Log("ジャンプ台の設定が足りていません");
         Destroy(this);
     }
 }
        public override void Update(float delta)
        {
            GameObject.MoveBy(Vector3.UnitY);

            if (ObjectCollision.Intersects(GameObject.Collision, _player.Collision))
            {
                GameObject.Scene.Game.ChangeScene(new WonScene());
            }

            GameObject.MoveBy(-Vector3.UnitY);
        }
Exemple #8
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.collider.tag == enemyTag01)
        {
            //踏みつけ判定になる高さ
            float stepOnHeight = (capcol.size.y * (stepOnRate / 100f));
            //踏みつけ判定のワールド座標
            float judgePos = transform.position.y - (capcol.size.y / 2f) + stepOnHeight;
            foreach (ContactPoint2D p in collision.contacts)
            {
                if (p.point.y < judgePos)
                {
                    ObjectCollision o = collision.gameObject.GetComponent <ObjectCollision>();
                    if (o != null)
                    {
                        otherJumpHeight = o.boundHeight; //踏んづけたものから跳ねる高さを取得する
                        o.playerStepOn  = true;          //踏んづけたものに対して踏んづけた事を通知する
                        isOtherJump     = true;
                        isJump          = false;
                        jumpTime        = 0.0f;
                    }
                    else
                    {
                        Debug.Log("ObjectCollisionが付いてないよ!");
                    }
                }
                else
                {
                    anim.Play("player_down");
                    isDown = true;
                    break;
                }
            }
        }

        else if (collision.collider.tag == moveFloorTag)
        {
            //踏みつけ判定になる高さ
            float stepOnHeight = (capcol.size.y * (stepOnRate / 100f));
            //踏みつけ判定のワールド座標
            float judgePos = transform.position.y - (capcol.size.y / 2f) + stepOnHeight;
            foreach (ContactPoint2D p in collision.contacts)
            {
                //動く床に乗っている
                if (p.point.y < judgePos)
                {
                    Debug.Log("動く床に乗ってる");
                    moveObj = collision.gameObject.GetComponent <MoveObject>();
                }
            }
        }
    }
        public override void Update(float delta = 1)
        {
            var direction = _target.Position - GameObject.Position;

            direction.Normalize();
            GameObject.MoveBy(direction * delta * _flySpeed);
            if (ObjectCollision.Intersects(_target.Collision, GameObject.Collision))
            {
                var targetHealthComponent = _target.GetComponent <HealthComponent>();
                targetHealthComponent.DealDamage(_damage);
                GameObject.Scene.RemoveGameObject(GameObject);
            }
        }
Exemple #10
0
        public override void Update(float delta)
        {
            var positionToMove = new Vector3(0, _speedY, 0);

            GameObject.MoveBy(positionToMove);

            if (ObjectCollision.Intersects(GameObject.Collision, _player.Collision))
            {
                _player.MoveBy(positionToMove);
            }

            if (GameObject.Position.Y >= _maxY || GameObject.Position.Y <= _minY)
            {
                _speedY *= -1;
            }
        }
Exemple #11
0
    void Update()
    {
        ObjectCollision playerInv = GameObject.FindGameObjectWithTag("Player").GetComponent <ObjectCollision>(); //creating a reference to the current players object so we can check the weapon status

        for (int i = 1; i <= nrWeapons; i++)                                                                     //checks every possible user input depending on how many weapons are in the inventory
        {
            if (Input.GetKeyDown("" + i))                                                                        //checking the status of whether the weapon status is active or not, so if the player has not picked up the rifle (in the games case), then it wont switch to it until the player picks it up
            {
                if (playerInv.activeWeapons[i - 1] == true)
                {
                    currentWeapon = i - 1;

                    SwitchWeapon(currentWeapon);
                }
            }
        }
    }
Exemple #12
0
    // private void SetAnimation()
    // {
    //     anim.SetBool("jump", isJump);
    //     anim.SetBool("ground", isGround);
    //     anim.SetBool("run", isRun);
    // }

    //敵との接触判定
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.collider.tag == enemyTag)
        {
            //踏みつけ判定になる高さ
            //float stepOnHeight = (capcol.size.y * (stepOnRate / 100f));

            // TODO:capcol.sizeの代わりになるものを探す
            float stepOnHeight = (1 * (stepOnRate / 100f));

            //踏みつけ判定のワールド座標
            //float judgePos = transform.position.y - (capcol.size.y / 2f) + stepOnHeight;

            // TODO:capcol.sizeの代わりになるものを探す
            float judgePos = transform.position.y - (1 / 2f) + stepOnHeight;

            foreach (ContactPoint2D p in collision.contacts)
            {
                if (p.point.y < judgePos)
                {
                    ObjectCollision o = collision.gameObject.GetComponent <ObjectCollision>();
                    if (o != null)
                    {
                        otherJumpHeight = o.boundHeight;        //踏んづけたものから跳ねる高さを取得する
                        o.playerStepOn  = true;                 //踏んづけたものに対して踏んづけた事を通知する
                        jumpPos         = transform.position.y; //ジャンプした位置を記録する
                        isOtherJump     = true;
                        isJump          = false;
                        jumpTime        = 0.0f;
                    }
                    else
                    {
                        Debug.Log("ObjectCollisionが付いてないよ!");
                    }
                }
                else
                {
                    //anim.Play("down");
                    isDown = true;
                    break;
                }
            }
        }
    }
Exemple #13
0
    private void OnCollisionEnter2D(Collision2D col)
    {
        if (col.gameObject.tag == enemyTag)
        {
            float stepOnHeight = (capcol.size.y * (stepOnRate / 100f));
            float judgePos     = transform.position.y - (capcol.size.y / 2f) + stepOnHeight;

            foreach (ContactPoint2D p in col.contacts)
            {
                if (p.point.y < judgePos)
                {
                    //もう一度跳ねる
                    ObjectCollision o = col.gameObject.GetComponent <ObjectCollision>();
                    if (o != null)
                    {
                        otherJumpHeight = o.boundHeight;
                        o.playerStepOn  = true;
                        isOtherJump     = true;
                        isJump          = false;
                        jumpTime        = 0.0f;
                    }
                    else
                    {
                        Debug.Log("ObjectCollisionがついてないよ!");
                    }
                }
                else
                {
                    //ダウンする
                    anim.Play("player_knockdown");
                    isDown = true;
                    GManager.instance.SubHeratNum();

                    GManager.instance.PlayerSE(downSE);

                    break;
                }
            }
        }
    }
Exemple #14
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.collider.tag != enemyTag)
        {
            return;
        }

        float           stepOnHeight = (capcol.size.y * (stepOnRate / 100f));
        float           judgePos     = transform.position.y - (capcol.size.y / 2f) + stepOnHeight;
        ObjectCollision o            = collision.gameObject.GetComponent <ObjectCollision>();

        foreach (ContactPoint2D contact in collision.contacts)
        {
            if (contact.point.y < judgePos)
            {
                isOtherJumping = true;

                if (o == null)
                {
                    Debug.Log("ObjectCollisionが付いてないよ!");
                }
                else
                {
                    otherJumpHeight   = o.boundHeight;
                    o.playerStepOn    = true;
                    currentJumpHeight = transform.position.y;
                    isOtherJumping    = true;
                    isJumping         = false;
                    jumpingTime       = 0;
                }
            }
            else
            {
                // ダウンする
                animator.Play("player_down");
                isDown = true;
                break;
            }
        }
    }
Exemple #15
0
    // 接触判定
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.collider.tag == enemyTag)
        {
            //踏みつけ判定になる高さ
            float stepOnHeight = (capcol.size.y * (stepOnRate / 100f));
            //踏みつけ判定のワールド座標
            float judgePos = transform.position.y - (capcol.size.y / 2f) + stepOnHeight;

            foreach (ContactPoint2D p in collision.contacts)
            {
                if (p.point.y < judgePos)
                {
                    ObjectCollision o = collision.gameObject.GetComponent <ObjectCollision> ();
                    if (o != null)
                    {
                        //踏んづけたものから跳ねる高さを取得する
                        otherJumpHeight = o.boundHeight;
                        //踏んづけたものに対して踏んづけた事を通知する
                        o.playerStepOn = true;
                        isOtherJump    = true;
                        isJump         = false;
                        jumpTime       = 0.0f;
                    }
                    else
                    {
                        Debug.Log("ObjectCollisionが付いてないよ!");
                    }
                }
                else
                {
                    anim.Play("player_lose");
                    isDown = true;
                    GManager.instance.SubHeartNum();
                    GManager.instance.PlaySE(downSE);
                    break;
                }
            }
        }
    }
        public override void Update(float delta)
        {
            GameObject.MoveBy(_direction * delta * _speed);
            ObjectCollision collision = GameObject.Collision;

            foreach (Game3DObject gameObject in GameObject.Scene.GameObjects)
            {
                if (gameObject == GameObject)
                {
                    continue;
                }

                if (gameObject.Collision != null)
                {
                    if (ObjectCollision.Intersects(gameObject.Collision, collision))
                    {
                        gameObject.GetComponent <HealthComponent>()?.DealDamage(_damage);
                        GameObject.Scene.RemoveGameObject(GameObject);
                    }
                }
            }
        }
Exemple #17
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.collider.tag == enemyTag)
     {
         // 踏みつけ判定になる高さ
         float stepOnHeight = (capcol.size.y * (stepOnRate / 100f));
         // 踏みつけ判定のワールド座標
         float judgePos = transform.position.y - (capcol.size.y / 2f) + stepOnHeight;
         foreach (ContactPoint2D p in collision.contacts)
         {
             if (p.point.y < judgePos)
             {
                 // もう一度跳ねる
                 ObjectCollision o = collision.gameObject.GetComponent <ObjectCollision>();
                 if (o != null)
                 {
                     otherJumpHeight = o.boundHeight;
                     o.playerStepOn  = true;
                     jumpPos         = transform.position.y;
                     isOtherJump     = true;
                     isJump          = false;
                     jumpTime        = 0.0f;
                 }
                 else
                 {
                     Debug.Log("ObjectCollisionがついてないよ");
                 }
             }
             else
             {
                 // ダウンする
                 anim.Play("player_down");
                 isDown = true;
                 break;
             }
         }
     }
 }
Exemple #18
0
        /// <summary>
        /// Проверка столкновения коллайдера с другими объектами с тегам
        /// </summary>
        /// <param name="gameObject">Пересекаемый объект или NULL</param>
        /// <param name="tag">Тэг объкта, с которым проверяется пересечение</param>
        /// <returns>Результат пересечения</returns>
        public bool CheckIntersects(out Game3DObject gameObject, string tag = "")
        {
            foreach (var collision in _collisions)
            {
                if (tag == "" || collision.GameObject.Tag != tag)
                {
                    continue;
                }

                if (collision != GameObject.Collision)
                {
                    var result = ObjectCollision.Intersects(GameObject.Collision, collision);
                    if (result)
                    {
                        gameObject = collision.GameObject;
                        return(result);
                    }
                }
            }

            gameObject = null;
            return(false);
        }
Exemple #19
0
 void Start()
 {
     col = GetComponent <BoxCollider2D>();
     rb  = GetComponent <Rigidbody2D>();
     oc  = GetComponent <ObjectCollision>();
     if (spriteObject != null && oc != null && col != null && rb != null)
     {
         spriteDefaultPos = spriteObject.transform.position;
         fallVelocity     = new Vector2(0, -fallSpeed);
         floorDefaultPos  = gameObject.transform.position;
         sr = spriteObject.GetComponent <SpriteRenderer>();
         if (sr == null)
         {
             Debug.Log("fallDownFloor インスペクターに設定し忘れがあります");
             Destroy(this);
         }
     }
     else
     {
         Debug.Log("fallDownFloor インスペクターに設定し忘れがあります");
         Destroy(this);
     }
 }
Exemple #20
0
        /// <summary>
        /// Обновление поведения
        /// </summary>
        /// <param name="delta">Время между кадрами</param>
        public override void Update(float delta)
        {
            if (_physicsComponent == null)
            {
                return;
            }

            if (_physicsComponent.IsGrounded)
            {
                if (!ObjectCollision.Intersects(GameObject.Collision, _ground.Collision))
                {
                    _ground = null;
                }
            }
            else
            {
                if (_colliderComponent.CheckIntersects(out Game3DObject ground, "ground"))
                {
                    _ground = ground;
                }
            }

            _physicsComponent.UpdateGrounded(_ground);
        }
Exemple #21
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        bool enemy     = (collision.collider.tag == enemyTag);
        bool moveFloor = (collision.collider.tag == moveFloorTag);
        bool fallFloor = (collision.collider.tag == fallFloorTag);
        bool jumpStep  = (collision.collider.tag == jumpStepTag);

        if (enemy || moveFloor || fallFloor || jumpStep)
        {
            // 踏みつけ判定になる高さ
            float stepOnHeight = (capcol.size.y * (stepOnRate / 100f));

            // 踏みつけ判定のワールド座標
            float judgePos = transform.position.y - (capcol.size.y / 2f) + stepOnHeight;

            foreach (ContactPoint2D p in collision.contacts)
            {
                // 敵の高さより、プレイヤーの高さのほうが大きい場合
                if (p.point.y < judgePos)
                {
                    if (enemy || fallFloor || jumpStep)
                    {
                        ObjectCollision o = collision.gameObject.GetComponent <ObjectCollision>();

                        if (o != null)
                        {
                            if (enemy || jumpStep)
                            {
                                otherJumpHeight = o.boundHeight;        // 踏んづけたものから跳ねる高さを取得する
                                otherJumpSpeed  = o.jumpSpeed;
                                o.playerStepOn  = true;                 // 踏んづけたものに対して踏んづけたことを通知する
                                jumpPos         = transform.position.y; // ジャンプした位置を記録する
                                isOtherJump     = true;
                                isJump          = false;
                                jumpTime        = 0.0f;
                            }
                            else if (fallFloor)
                            {
                                o.playerStepOn = true;
                            }
                        }
                        else
                        {
                            Debug.Log("ObjectCollisionが付いてないよ!");
                        }
                    }
                    else if (moveFloor)
                    {
                        moveObj = collision.gameObject.GetComponent <MoveObject>();
                    }
                }
                else
                {
                    if (enemy)
                    {
                        ReceiveDamage(true);
                        break;
                    }
                }
            }
        }
    }
Exemple #22
0
    void Movement(GameObject target, Rigidbody2D rbTarget, ObjectSettings targetSettings, ObjectCollision targetCollision, int index)
    {
        float speedReduction = SlowDownValue(index);
        float speedIncrease  = 0;
        float actualSpeed    = maxSpeed - speedReduction + speedIncrease;

        rbTarget.gravityScale = 0;

        if (!targetSettings.isStatic)
        {
            #region dynamic telephathy
            if ((touch.TapPosition(index).x - target.transform.position.x >= 0 && !targetCollision.right))
            {
                if (rbTarget.velocity.x < actualSpeed)
                {
                    rbTarget.AddForce(Vector2.right * (strength - rbTarget.mass));
                }
                else
                {
                    rbTarget.AddForce(Vector2.left * (strength * 1.5f - rbTarget.mass));
                }
            }

            if ((touch.TapPosition(index).x - target.transform.position.x <= 0 && !targetCollision.left))
            {
                if (rbTarget.velocity.x > -actualSpeed)
                {
                    rbTarget.AddForce(Vector2.left * (strength - rbTarget.mass));
                }
                else
                {
                    rbTarget.AddForce(Vector2.right * (strength * 1.5f - rbTarget.mass));
                }
            }

            if ((touch.TapPosition(index).y - target.transform.position.y >= 0 && !targetCollision.up))
            {
                if (rbTarget.velocity.y < actualSpeed)
                {
                    rbTarget.AddForce(Vector2.up * (strength - rbTarget.mass));
                }
                else
                {
                    rbTarget.AddForce(Vector2.down * (strength * 1.5f - rbTarget.mass));
                }
            }

            if ((touch.TapPosition(0).y - target.transform.position.y <= 0 && !targetCollision.down))
            {
                if (rbTarget.velocity.y > -actualSpeed)
                {
                    rbTarget.AddForce(Vector2.down * (strength - rbTarget.mass));
                }
                else
                {
                    rbTarget.AddForce(Vector2.up * (strength * 1.5f - rbTarget.mass));
                }
            }
            #endregion
        }
        else
        {
            #region static telepathy

            /*
             * if (TouchInputs.GC.TapBegan(0))
             * {
             *  targetSettingsA.pivot.transform.position = TouchInputs.GC.TapPosition(0);
             * }
             *
             * Vector3 oldDiff = targetSettingsA.pivot.transform.position - targetA.transform.position;
             * Vector3 newDiff = TouchInputs.GC.TapPosition(0) - targetA.transform.position;
             *
             * float oldRot = Mathf.Atan2(oldDiff.y, oldDiff.x) * Mathf.Rad2Deg;
             * float newRot = Mathf.Atan2(newDiff.y, newDiff.x) * Mathf.Rad2Deg;
             *
             * if (newRot < oldRot)
             * {
             *  targetA.transform.Rotate(Vector3.forward * 30 * Time.deltaTime);
             * }
             * if (newRot > oldRot)
             * {
             *  targetA.transform.Rotate(Vector3.forward * -30 * Time.deltaTime);
             * }
             * // targetA.transform.rotation = Quaternion.Euler(0f, 0f, rot_z - pivot);
             *
             * InGameDebug.GC.NewDebug("" + oldRot, "old");
             * InGameDebug.GC.NewDebug("" + newRot, "new");
             */
            #endregion
        }
    }
Exemple #23
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        bool  enemy          = (collision.collider.tag == enemyTag);
        bool  moveFloor      = (collision.collider.tag == moveFloorTag);
        bool  fallFloor      = (collision.collider.tag == fallFloorTag);
        bool  floor          = (collision.collider.tag == FloorTag);
        float collisionY     = collision.transform.position.y;
        float thisCollisionY = transform.position.y;

        if (enemy || moveFloor || fallFloor || floor)
        {
            if (collisionY < thisCollisionY)
            {
                Debug.Log("落ちること");
            }
            //踏みつけ判定になる高さ
            float stepOnHeight = (capcol.size.y * (stepOnRate / 100f));

            //踏みつけ判定のワールド座標
            float judgePos = transform.position.y - (capcol.size.y / 2.5f) + stepOnHeight;

            foreach (ContactPoint2D p in collision.contacts)
            {
                //Debug.Log("p -> x:" + p.point.x);
                //Debug.Log("p -> y:" + p.point.y);
                // if (floor) {
                //     float playerPos = transform.position.y - (capcol.size.y / 0.7f);
                //     if (p.point.y > playerPos)
                //     {
                //         p.collider.isTrigger = true;
                //         Debug.Log("p -> y:" + p.point.y);
                //     }
                // }

                if (p.point.y < judgePos)
                {
                    if (enemy || floor || fallFloor)
                    {
                        ObjectCollision o = collision.gameObject.GetComponent <ObjectCollision>();
                        if (o != null)
                        {
                            if (enemy)
                            {
                                otherJumpHeight = o.boundHeight;        //踏んづけたものから跳ねる高さを取得する
                                o.playerStepOn  = true;                 //踏んづけたものに対して踏んづけた事を通知する
                                jumpPos         = transform.position.y; //ジャンプした位置を記録する
                                isOtherJump     = true;
                                isJump          = false;
                                jumpTime        = 0.0f;
                            }
                            else if (fallFloor)
                            {
                                o.playerStepOn = true;
                            }
                            else if (floor)
                            {
                                o.playerStepOn = true;
                            }
                        }
                        else
                        {
                            //Debug.Log("ObjectCollisionが付いてないよ!");
                        }
                    }
                    else if (moveFloor)
                    {
                        moveObj = collision.gameObject.GetComponent <MoveObject>();
                    }
                }
                else
                {
                    if (enemy)
                    {
                        ReceiveDamage(true);
                        break;
                    }
                }
            }
        }
    }
Exemple #24
0
 // Use this for initialization
 void Start()
 {
     _spell_manager    = GameObject.Find("SpellManager").GetComponent <SpellManager>();
     _object_collision = GetComponent <ObjectCollision>();
     _particles        = GetComponentInChildren <ParticleSystem> ();
 }
Exemple #25
0
 public void ObjectNeeded(GameObject soil, Animator popUpBox)
 {
     this.popUpBox   = popUpBox;
     this.soilObject = soil.GetComponent <ObjectCollision>();
     this.soil       = soil.transform.Find("plant").GetComponent <Soil>();
 }
Exemple #26
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        bool enemy     = (collision.collider.tag == enemyTag);
        bool moveFloor = (collision.collider.tag == moveFloorTag);
        bool fallFloor = (collision.collider.tag == fallFloorTag);
        bool jumpStep  = (collision.collider.tag == jumpStepTag);

        if (enemy || moveFloor || fallFloor || jumpStep)
        {
            //踏みつけ判定になる高さ
            float stepOnHeight = (capcol.size.y * (stepOnRate / 100f));

            //踏みつけ判定のワールド座標
            float judgePos = transform.position.y - (capcol.size.y / 2f) + stepOnHeight;

            foreach (ContactPoint2D p in collision.contacts)
            {
                if (p.point.y < judgePos)
                {
                    if (enemy || fallFloor || jumpStep)
                    {
                        ObjectCollision o = collision.gameObject.GetComponent <ObjectCollision>();
                        if (o != null)
                        {
                            if (enemy || jumpStep)
                            {
                                otherJumpHeight = o.boundHeight;        //踏んづけたものから跳ねる高さを取得する
                                otherJumpSpeed  = o.jumpSpeed;          //ジャンプするスピード
                                o.playerStepOn  = true;                 //踏んづけたものに対して踏んづけた事を通知する
                                jumpPos         = transform.position.y; //ジャンプした位置を記録する
                                isOtherJump     = true;
                                isJump          = false;
                                jumpTime        = 0.0f;
                            }
                            else if (fallFloor)
                            {
                                o.playerStepOn = true;
                            }
                        }
                        else
                        {
                            Debug.Log("ObjectCollisionが付いてないよ!");
                        }
                    }
                    else if (moveFloor)
                    {
                        moveObj = collision.gameObject.GetComponent <MoveObject>();
                    }
                }
                else
                {
                    if (enemy)
                    {
                        ReceiveDamage(true);
                        break;
                    }
                }
            }
        }

        /*
         * if (collision.collider.tag == enemyTag)
         * {
         *  //踏みつけ判定になる高さ
         *  float stepOnHeight = (capcol.size.y * (stepOnRate / 100f));
         *  //踏みつけ判定のワールド座標
         *  float judgePos = transform.position.y - (capcol.size.y / 2f) + stepOnHeight;
         *  foreach (ContactPoint2D p in collision.contacts)
         *  {
         *      if (p.point.y < judgePos)
         *      {
         *          //もう一度跳ねる
         *          ObjectCollision o = collision.gameObject.GetComponent<ObjectCollision>();
         *          if (o != null)
         *          {
         *              otherJumpHeight = o.boundHeight;    //踏んづけたものから跳ねる高さを取得する
         *              o.playerStepOn = true;        //踏んづけたものに対して踏んづけた事を通知する
         *              jumpPos = transform.position.y; //ジャンプした位置を記録する
         *              isOtherJump = true;
         *              isJump = false;
         *              jumpTime = 0.0f;
         *          }
         *          else
         *          {
         *              Debug.Log("ObjectCollisionが付いてないよ!");
         *          }
         *      }
         *      else
         *      {
         *          //ダウンする
         *
         *         // anim.Play("player_down");
         *          //isDown = true;
         *          ReceiveDamage(true);
         *          break;
         *      }
         *  }
         * }
         * //動く床
         * else if (collision.collider.tag == moveFloorTag)
         * {
         *  //踏みつけ判定になる高さ
         *  float stepOnHeight = (capcol.size.y * (stepOnRate / 100f));
         *  //踏みつけ判定のワールド座標
         *  float judgePos = transform.position.y - (capcol.size.y / 2f) + stepOnHeight;
         *  foreach (ContactPoint2D p in collision.contacts)
         *  {
         *      //動く床に乗っている
         *      if (p.point.y < judgePos)
         *      {
         *          moveObj = collision.gameObject.GetComponent<MoveObject>();
         *      }
         *  }
         * }*/
    }
Exemple #27
0
 public GameObject(Type gameType)
 {
     ObjType = gameType;
     item = new TextureItem((System.Drawing.Bitmap)GameCore.CoreFiles.getTexture(ObjType).Clone(), gameType);
     switch (ObjType)
     {
         case Type.Barn:
             Health = 100;
             Population = 3;
             break;
         case Type.House:
             Health = 200;
             Population = 5;
             break;
         case Type.Outhouse:
             Health = 300;
             Population = 10;
             break;
         case Type.BigBarn:
             Health = 400;
             Population = 30;
             break;
         case Type.Shop:
             Health = 250;
             Population = 10;
             break;
         case Type.Hay:
             Health = 50;
             Feeds = 10;
             break;
         case Type.Windmil:
             Health = 100;
             Population = 3;
             break;
         case Type.Footman:
             Health = 250;
             Damage = 1;
             RequiredXP = 100;
             Population = 1;
             Moveable = true;
             break;
         case Type.Grass:
             break;
     }
     MaxHealth = Health;
     Health -= 20;
     OnCollision += new ObjectCollision(GameObject_OnCollision);
 }