Beispiel #1
0
    void OnCollisionEnter(Collision other)
    {
        controller = GetComponentInParent <MovableObjectController>();
        if (other.transform.tag == Tags.RideOn || controller == null)
        {
            return;
        }

        Rigidbody rigidBody = other.transform.GetComponent <Rigidbody>();

        if (isOver)
        {
            isStop = true;
            if (rigidBody == null || (other.transform.GetComponent <GraspItem>() == null))
            {
                controller.Burying();
                collisionColorObject = other.transform.GetComponent <ColorObjectBase>();
            }
        }
        else
        {
            if (rigidBody == null || (other.transform.GetComponent <GraspItem>() == null))
            {
                if (other.transform == transform)
                {
                    return;
                }
                controller.Collision();
                collisionColorObject = other.transform.GetComponent <ColorObjectBase>();
            }
        }
    }
Beispiel #2
0
    void OnTriggerEnter(Collider other)
    {
        ColorObjectBase colorObject = other.GetComponent <ColorObjectBase>();

        if (colorObject == null)
        {
            return;
        }

        if (colorObject.GetComponent <GraspItem>() != null)
        {
            collisionItem = colorObject.GetComponent <GraspItem>();

            // &の結果はブロックと消去グリッドの共通色
            // その色がブロックの色を全て含んでないならreturn
            if ((colorObject.objectColor.state & color.state) < colorObject.objectColor.state)
            {
                return;
            }

            burstParticle.transform.position = colorObject.transform.position;
            burstParticle.startColor         = (Color)colorObject.objectColor;
            burstParticle.Play();
            colorObject.GetComponent <GraspItem>().Respawn();
        }
    }
Beispiel #3
0
 protected override void Update()
 {
     if (colorObstacle != null && colorObstacle.isDisappearance)
     {
         // もし衝突していた物体が消えたなら、コントローラ側にそれを知らせる
         controller.CollisionDisappearance();
         colorObstacle = null;
     }
 }
Beispiel #4
0
 protected override void Update()
 {
     if (collisionColorObject != null)
     {
         if (collisionColorObject.isDisappearance)
         {
             controller.CollisionDisappearance();
             collisionColorObject = null;
         }
     }
 }
Beispiel #5
0
 protected override void Update()
 {
     if (collisionColorObject != null)
     {
         if (collisionColorObject.isDisappearance)
         {
             controller.CollisionDisappearance();
             collisionColorObject = null;
         }
     }
 }
    public void RenderMaterialColors(List <Control> controls)
    {
        if (controls.Count <= 0)
        {
            return;
        }

        for (int i = 0; i < controls.Count; i++)
        {
            ColorObjectBase colorObject = controls[i].ColorObjectBase;

            colorObject.UpdateCurrentColor(ColorAssignments[i]);
        }
    }
Beispiel #7
0
    private void OnCollisionEnter(Collision other)
    {
        controller.Collision();

        if (other.transform.GetComponent <Rigidbody>() == null)
        {
            return;
        }

        // 途中で消失する可能性のあるものにぶつかったときはそれを覚えておく
        if (other.transform.GetComponent <Rigidbody>().constraints == RigidbodyConstraints.FreezeAll)
        {
            colorObstacle = other.transform.GetComponent <ColorObjectBase>();
        }
    }
Beispiel #8
0
    protected override void Update()
    {
        if (collisionColorObject == null)
        {
            return;
        }

        // ぶつかっていたカラーオブジェクトが消失したので
        // コントローラへ通知する
        if (collisionColorObject.isDisappearance)
        {
            controller.CollisionDisappearance();
            collisionColorObject = null;
        }
    }
    static void RaiseEvent(ColorObjectEvent in_Event, ColorObjectBase callingColorObject)
    {
        if (in_Event != null)
        {
            in_Event(callingColorObject);

            if (bPrintDebug)
            {
                Debug.Log("Event: " + in_Event.Method);
            }
        }
        else
        {
            PrintNullEventWarning(in_Event.ToString());
        }
    }
Beispiel #10
0
    void OnTriggerEnter(Collider other)
    {
        if (grabbedObject != null)
        {
            return;
        }

        // hitListに何か含まれていればreturn。(拾えるもの優先)
        foreach (GraspItem listItem in hitList)
        {
            ColorObjectBase colorObject = listItem.GetComponent <ColorObjectBase>();
            if (colorObject != null)
            {
                if (!colorObject.isDisappearance)
                {
                    return;
                }
            }
            else
            {
                return;
            }
        }

        if (other.GetComponent <EventObject>() != null)
        {
            //other.GetComponent<EventObject>().ViewIcon();
        }

        // 掴めるものか
        if (other.GetComponent <GraspItem>() == null)
        {
            return;
        }

        // すでにhitListに含まれていればreturn
        if (hitList.Exists((item) => item == other.GetComponent <GraspItem>()))
        {
            return;
        }

        hitList.Add(other.GetComponent <GraspItem>());
    }
Beispiel #11
0
    private void HandleColorObjectButtonSelected(ColorObjectBase callingColorObject)
    {
        string message = callingColorObject.ToString();

        ColorOption promptColor = GetColorOptionFromMaterial();

        if (callingColorObject.CurrentColor == promptColor)
        {
            EventManager.RaiseColorMatch(callingColorObject.OwningPlayer);
            message += " SUCCESS!";
            AssignRandomColor();
        }
        else
        {
            EventManager.RaiseColorMismatch(callingColorObject.OwningPlayer);
            message += " FAIL!";
        }

        print(message);
    }
Beispiel #12
0
    void OnTriggerStay(Collider other)
    {
        if (grabbedObject != null)
        {
            return;
        }

        // hitListに何か含まれていればreturn。(拾えるもの優先)
        foreach (GraspItem listItem in hitList)
        {
            ColorObjectBase colorObject = listItem.GetComponent <ColorObjectBase>();
            if (colorObject != null)
            {
                if (!colorObject.isDisappearance)
                {
                    return;
                }
            }
            else
            {
                return;
            }
        }

        // 目の前の物を調べる
        // 調べられるもの全てを配列として取得
        Component[] checkComponents = other.GetComponents(typeof(ICheckEvent));
        if (checkComponents == null)
        {
            return;
        }

        ExamineIconManager.HideIcon();
        if ((Input.GetKeyDown(KeyCode.E) || Input.GetMouseButtonDown(1)) && !player.isIrradiation)
        {
            foreach (ICheckEvent component in checkComponents)
            {
                component.Check();
            }
        }
    }
    private void Initialize()
    {
        _light           = GetComponent <Light>();
        _light.intensity = 0;

        if (_colorLightDataSO)
        {
            UpdateColorLightData();
        }

        _maxIntensity = _baseIntensity;

        if (transform.parent)
        {
            _parentColorObjectNew = transform.GetComponentInParent <ColorObjectBase>();
        }
        else
        {
            Debug.LogError(this + " requires a parent GameObject of type " + _parentColorObjectNew.GetType() + ".");
        }
    }
Beispiel #14
0
    private void OnCollisionEnter(Collision other)
    {
        controller = GetComponentInParent <MovableObjectController>();
        if (other.transform.tag == Tags.RideOn || controller == null)
        {
            return;
        }

        var rigidBody = other.transform.GetComponent <Rigidbody>();

        if (isOver)
        {
            // カラーブロックが消失状態で重なっている間に再生された
            // つまり埋まった
            isStop = true;
            if (rigidBody == null || (other.transform.GetComponent <GraspItem>() == null))
            {
                // 埋まった時の処理
                controller.Burying();
                collisionColorObject = other.transform.GetComponent <ColorObjectBase>();
            }
        }
        else
        {
            // 何かにぶつかったので停止
            if (rigidBody == null || (other.transform.GetComponent <GraspItem>() == null))
            {
                if (other.transform == transform)
                {
                    return;
                }
                controller.Collision();
                collisionColorObject = other.transform.GetComponent <ColorObjectBase>();
            }
        }
    }
Beispiel #15
0
    /// <summary>
    /// 対象地点へ照射
    /// 目標地点との間に障害物があれば遮られる
    /// </summary>
    /// <param name="point">目標地点</param>
    public bool IrradiationToTarget(Vector3 point)
    {
        bool       isHit = false;
        RaycastHit hit;

        transform.LookAt(point);
        int layerMask = ~((1 << Layers.Leaser.layer) | (1 << Layers.IgnoreRaycast.layer));

        if (Physics.Raycast(transform.position, transform.forward, out hit, length, layerMask))
        {
            isHit = true;

            if (Application.isPlaying)
            {
                if (hitPointLight == null)
                {
                    hitPointLight = (GameObject)Instantiate(hitPointLightPrefab, Vector3.zero, Quaternion.identity);
                    hitPointLight.transform.parent             = transform.parent;
                    hitPointLight.GetComponent <Light>().color = (Color)color;
                }

                // 命中点に明かりを表示する
                hitPointLight.transform.position = hit.point - transform.forward * 0.2f;
                hitPointLight.transform.forward  = transform.forward;
            }

            // 命中した地点に合わせてレーザーの形状を変更
            transform.localScale = new Vector3(1.0f, 1.0f, hit.distance + 0.001f);

            ColorObjectBase colorObject = hit.transform.GetComponent <ColorObjectBase>();

            // 命中した地点がカラーオブジェクトなら
            if (colorObject != null)
            {
                // 照射メッセージを送る
                colorObject.Irradiated(color);

                // 白い箱なら反射
                if (colorObject.objectColor.state == ColorState.WHITE && reflectCount > 0)
                {
                    if (reflectedLaser == null)
                    {
                        Reflected();
                        reflectedLaser.reflectCount--;
                    }

                    Vector3 r = Vector3.Reflect(transform.forward, hit.normal);
                    reflectedLaser.transform.position = hit.point;
                    reflectedLaser.transform.forward  = r;
                    reflectedLaser.length             = length - hit.distance;
                    if (reflectedLaser.reflectCount <= 0)
                    {
                        reflectedLaser.reflectCount = 0;
                    }
                    reflectedLaser.IrradiationToTarget(hit.point + r * length);
                }
                else
                {
                    // 反射しないので反射レーザーが生成されていれば削除
                    if (reflectedLaser != null)
                    {
                        Destroy(reflectedLaser.gameObject);
                    }
                }
            }
            else
            {
                // 反射しないので反射レーザーが生成されていれば削除
                if (reflectedLaser != null)
                {
                    Destroy(reflectedLaser.gameObject);
                }
            }
        }
        else
        {
            transform.localScale = new Vector3(1.0f, 1.0f, length);

            // そもそも当たってないので色々削除
            if (Application.isPlaying)
            {
                Destroy(hitPointLight);
            }

            if (reflectedLaser != null)
            {
                Destroy(reflectedLaser.gameObject);
            }
        }

        return(isHit);
    }
 public static void RaiseColorObjectButtonSelected(ColorObjectBase callingColorObject) => RaiseEvent(OnColorObjectButtonSelected, callingColorObject);
Beispiel #17
0
    void OnCollisionEnter(Collision other)
    {
        controller = GetComponentInParent<MovableObjectController>();
        if (other.transform.tag == Tags.RideOn || controller == null)
        {
            return;
        }

        Rigidbody rigidBody = other.transform.GetComponent<Rigidbody>();

        if (isOver)
        {
            isStop = true;
            if (rigidBody == null || (other.transform.GetComponent<GraspItem>() == null))
            {
                controller.Burying();
                collisionColorObject = other.transform.GetComponent<ColorObjectBase>();
            }
        }
        else
        {
            if (rigidBody == null || (other.transform.GetComponent<GraspItem>() == null))
            {
                controller.Collision();
                collisionColorObject = other.transform.GetComponent<ColorObjectBase>();
            }
        }
    }