Beispiel #1
0
    float lastTimeOfGettingLightElement = 0;        //为了放止在光球被销毁之前发生二次拾取

    public void OnLighting(RaycastHit2D hit, Vector3 direction, RayLight light)
    {
        if (isPausing || GameGlobal.GameData.isPausing)
        {
            return;
        }
        //判断人物是否能随光线移动
        bool flag = false;

        if (PlayerParticleController.lightQuantity > 0)
        {
            RayLight.LightColor playerColor = RayLight.GetLight(PlayerParticleController.lightQuantity).lightColor;
            RayLight.LightColor lightColor  = light.lightColor;
            if (playerColor == RayLight.LightColor.white)
            {
                flag = true;
            }
            else
            {
                if (playerColor == lightColor)
                {
                    flag = true;
                }
            }
        }
        //移动人物
        if (flag)
        {
            transform.Translate(-direction * Time.deltaTime * velocityOnLighting);
            if (verticalVelocity < 0)
            {
                verticalVelocity = 0;
            }
        }
    }
Beispiel #2
0
    bool haveFence(RaycastHit2D[] hits)
    {
        if (hits == null)
        {
            return(false);
        }
        else
        {
            bool flag = false;
            foreach (RaycastHit2D hit in hits)
            {
                if (!hit.collider.isTrigger)
                {
                    if (hit.collider.tag != "ColorfulPlatform")
                    {
                        flag = true;
                    }
                    //若目标平台是有颜色需求的
                    else
                    {
                        //获取目标平台脚本控件
                        ColorfulPlatform platInstance = hit.collider.transform.parent.parent.GetComponent <ColorfulPlatform>();

                        RayLight            playerLight   = RayLight.GetLight(PlayerParticleController.lightQuantity);
                        RayLight.LightColor platformColor = hit.collider.transform.parent.parent.GetComponent <ColorfulPlatform>().platformColor;
                        //若颜色一样
                        if (playerLight.lightColor == platformColor)
                        {
                            flag = true;
                        }
                        //反之
                        else
                        {
                            if (playerLight.lightColor == RayLight.LightColor.white &&
                                playerLight.LightQuantity != 0)
                            {
                                flag = true;
                            }
                            else
                            {
                                flag = false;
                                platInstance.OnScene();
                            }
                        }
                    }
                }
            }
            return(flag);
        }
    }