Exemple #1
0
//	void Awake () {
//		Init ();
//	}

    public void init(FightEntity entity)
    {
        this.fightEntity     = entity;
        this.clientRunTime   = (ClientRunTime)entity.map;
        this.localPositionV2 = new Vector2();
        this.localScaleV3    = new Vector3(1, 1, 1);
        this.materialList    = new List <Material> ();
        Material material;

        //一次性取出所有 MeshRenderer ParticleSystem
        Renderer[] renderers = this.GetComponentsInChildren <Renderer>();
        foreach (Renderer renderer in renderers)
        {
            material          = renderer.material;
            renderer.material = material;
            materialList.Add(material);
        }
        imageArr = this.GetComponentsInChildren <Image>();

        if (this.fightEntity.type == ConfigConstant.ENTITY_PLAYER)
        {
            Image image = Tools.FindChild2("Canvas/faceImage", this.gameObject).transform.GetChild(0).GetComponent <Image> ();
            ClientPlayerEntity player = (ClientPlayerEntity)entity;
            ResFactory.setHeadSprite(player.headUrl, image, player.uid);
            //Sprite spr = ((Player)player.view).faceSprite;
            //image.sprite = spr;
        }

        lastAlpha = 1f;
        ChangeAlpha(0);
    }
    ///弹出并显示一条播报
    public void popRadio()
    {
        clearTween();
        if (radiolist.Count > 0)
        {
            LTDescr ltd;


            currentRadio = radiolist [0];
            radiolist.RemoveAt(0);
            currentRadioTime = 0;
            //temp
//			currentRadio.scale = 2f;

            //首阶段显现时间
            float timeApper = 0.2f / currentRadio.scale;
            //次阶段缓动动画时间
            float timeEnter = 0.1f;
            //第三阶段缓动动画时间
            float timeNext = 0.2f;
            //最后阶段缓动动画时间
            float timeFinish = 0.2f;

            Color outlineColor;
            //更新双方和文字
            if (currentRadio.player1 != null)
            {
                player1FaceImage.gameObject.SetActive(true);
                player1FrameImage.gameObject.SetActive(true);
                ResFactory.setHeadSprite(currentRadio.player1.headUrl, player1FaceImage, currentRadio.player1.uid);
                player1FrameImage.color = currentRadio.player1.getTeamColor(2);
//				lineImage.color = currentRadio.player1.getTeamColor (2);

                //头像偏移
                ltd           = LeanTween.moveLocalX(player1FrameImage.gameObject, player1LocalPosition.x + offsetTween, timeEnter);
                ltd.tweenType = LeanTweenType.easeOutSine;
                ltd.delay     = timeApper * 0.5f;

                outlineColor = currentRadio.player1.getTeamColor(2);

                bgImage.transform.localPosition = bgImagePosition0;
                bgInnerImage.gameObject.SetActive(false);
                radioText.rectTransform.sizeDelta = radioTextSizeDelta0;
            }
            else
            {
                //没有主动玩家,一般性播报
                player1FaceImage.gameObject.SetActive(false);
                player1FrameImage.gameObject.SetActive(false);

                outlineColor = currentRadio.color;

                bgImage.transform.localPosition = bgImagePosition1;
                bgInnerImage.gameObject.SetActive(true);
                radioText.rectTransform.sizeDelta = radioTextSizeDelta1;
            }

            if (currentRadio.player2 != null)
            {
                player2FaceImage.gameObject.SetActive(true);
                player2FrameImage.gameObject.SetActive(true);
                ResFactory.setHeadSprite(currentRadio.player2.headUrl, player2FaceImage, currentRadio.player2.uid);
                player2FrameImage.color = currentRadio.player2.getTeamColor(2);

                ltd           = LeanTween.moveLocalX(player2FrameImage.gameObject, player2LocalPosition.x - offsetTween, timeEnter);
                ltd.tweenType = LeanTweenType.easeOutSine;
                ltd.delay     = timeApper * 0.5f;

                //击杀红叉图片缩放,透明显现变化颜色
                float   scale = 3f;
                Vector3 v3    = new Vector3(scale, scale, scale);
                deadImage.transform.localScale = v3;
                ltd           = LeanTween.scale(deadImage.gameObject, deadLocalScale, timeFinish);
                ltd.tweenType = LeanTweenType.easeOutBack;
                ltd.delay     = timeApper + timeEnter + timeNext * 0.5f;

                deadImage.color = colorStart;
                ltd             = LeanTween.value(this.gameObject, (Color color) =>
                {
                    deadImage.color = color;
                },
                                                  colorStart,
                                                  Color.white,
                                                  timeFinish * 0.5f
                                                  );
                ltd.tweenType = LeanTweenType.easeOutSine;
                ltd.delay     = timeApper + timeEnter + timeNext * 0.5f;
            }
            else
            {
                player2FaceImage.gameObject.SetActive(false);
                player2FrameImage.gameObject.SetActive(false);
            }

            //文字和外发光
            radioTextOutline.effectColor = outlineColor;
            radioText.text = currentRadio.info;

            //音效
            if (currentRadio.player1 != null && currentRadio.player2 != null)
            {
                int player1Type = currentRadio.player1.teamType;
                int player2Type = currentRadio.player2.teamType;
                if (player1Type == 0)
                {
                    playVoice(currentRadio.voiceIDo);
                }
                else if (player2Type == 0)
                {
                    playVoice(currentRadio.voiceDoMe);
                }
                else if (player1Type == 1)
                {
                    playVoice(currentRadio.voiceAllyDo);
                }
                else if (player1Type == 2)
                {
                    playVoice(currentRadio.voiceEnermyDo);
                }
                else
                {
                    playVoice(currentRadio.voice);
                }
            }
            else
            {
                playVoice(currentRadio.voice);
            }

//			Vector3 position;
//			if (false && currentRadio.cardId != null) {
//				//有击杀卡片展示
//				cardImage.gameObject.SetActive (true);
//				cardImage.sprite = ViewUtils.LoadSprite(currentRadio.cardId);
//
//				position = new Vector3();
//				position.x = -radioText.preferredWidth * 0.5f - 22f;
//				cardImage.transform.localPosition = position;
//
//				position = new Vector3();
//				position.x = 22f;
//				radioText.transform.localPosition = position;
//			} else {
            //无击杀卡片展示
//				cardImage.gameObject.SetActive (false);
//
//				position = new Vector3();
//				radioText.transform.localPosition = position;
//			}


            GameObject lightningGo       = null;
            Animator   lightningAnimator = null;
            if (currentRadio.lightningScale > 0)
            {
                if (currentRadio.player1 == null || currentRadio.player1.teamType <= 1)
                {
                    //蓝色闪电
                    lightningGo       = lightningGo1;
                    lightningAnimator = lightningAnimator1;
                }
                else
                {
                    //红色闪电
                    lightningGo       = lightningGo2;
                    lightningAnimator = lightningAnimator2;
                }
            }

            //击杀文字缩放
            if (currentRadio.scale > 1f)
            {
                float   scale1 = (currentRadio.scale - 1f) * 5 + 1;
                float   scale2 = (currentRadio.scale - 1f) * 2 + 1;
                Vector3 v3_1   = new Vector3(scale1, scale1, scale1);
                Vector3 v3_2   = new Vector3(scale2, scale2, scale2);

                radioText.transform.localScale = v3_1;

                ltd            = LeanTween.scale(radioText.gameObject, v3_2, timeEnter);
                ltd.delay      = timeApper * 0.5f;
                ltd.onComplete = () => {
                    LTDescr ltd_ = LeanTween.scale(radioText.gameObject, textLocalScale, timeNext);
                    ltd_.tweenType = LeanTweenType.easeOutBack;

                    if (lightningGo != null)
                    {
                        float   scale = currentRadio.lightningScale;
                        Vector3 v3    = new Vector3(scale, scale, scale);
                        LeanTween.delayedCall(timeEnter * 0.5f, () => {
                            //闪电
                            lightningAnimator.Play("play");
                        });
                    }
                };
                //透明显现
                radioText.color = colorStart;
                ltd             = LeanTween.value(this.gameObject, (Color color) =>
                {
                    radioText.color = color;
                },
                                                  colorStart,
                                                  Color.white,//player1Color
                                                  timeEnter
                                                  );
                ltd.delay = timeApper * 0.5f;
            }

            //整体透明显现
            ltd = LeanTween.value(this.gameObject, (float value) =>
            {
                canvasGroup.alpha = value;
            },
                                  canvasGroup.alpha,
                                  1,
                                  timeApper
                                  );
            ltd.onComplete = () => {
                isSwitch = false;
            };
        }
    }
Exemple #3
0
    public override void init()
    {
        this.mainScale = Convert.ToSingle(((Dictionary <string, object>)ConfigConstant.scoreConfig[this._playerEntity.fightResult.scoreLevel])["mainScale"]);
        this.avatar    = ResFactory.createObject <AvatarView>(ResFactory.instance.avatar);
        this.avatar.init(Tools.FindChild2("ship", this.skewBody.gameObject).transform, this._playerEntity);
        base.init();


        /****************************加入边界************************/
        this.scene.edgeHintController.addFightObject(this._playerEntity.teamIndex == this.clientRunTime.teamIndex ? 1 : 2, this._fightEntity);
        /****************************名字************************/
        //Biggo修改
        this.nameText.text  = this._playerEntity.name;
        this.nameText.color = this._playerEntity.getTeamColor(0);
        ResFactory.setHeadSprite(this._playerEntity.headUrl, Tools.FindChild2("personEarth/Canvas/faceImage/Image", this.gameObject).GetComponent <Image>(), this._playerEntity.uid);
        /****************************outLine************************/
        Tools.FindChild2("personEarth/Canvas/nameText", this.gameObject).GetComponent <Outline>().effectColor = this._playerEntity.getTeamColor(1);
        /****************************frameImage************************/
        Tools.FindChild2("personEarth/Canvas/frameImage", this.gameObject).GetComponent <Image>().color = this._playerEntity.getTeamColor(2);
        /****************************装备************************/
        for (int i = 0, len = ConfigConstant.PART_COUNT; i < len; i++)
        {
            this.parts.Add(new PartSlider(this, i));
        }
        this.shipEntryTween(true);
        /****************************事件************************/
        //TODO:这个是否要与callView  dead进行融合???
        this._fightEntity.addListener(EventConstant.ALIVED, (e) => {
            this.gameObject.SetActive(this._fightEntity.alived);
            this.changeMove(1);
            if (!this._fightEntity.alived)
            {
                //死亡了。。。
                this.clientRunTime.addEffect("bangDead", this._fightEntity.position);
            }
            else
            {
                this.avatar.reset();
                this.shipEntryTween(true);
                this.clientRunTime.addEffect("bangBorn", this._fightEntity.position);
                for (int i = 0; i < ConfigConstant.PART_COUNT; i++)
                {
                    this.parts[i].updatePart();
                }
            }
        });

        this._playerEntity.addListener(EventConstant.LEVEL_CHANGE, (MainEvent e) => {
            this.mainScale = Convert.ToSingle(((Dictionary <string, object>)ConfigConstant.scoreConfig[this._playerEntity.fightResult.scoreLevel])["mainScale"]);
            this.shipEntryTween(false);
            Dictionary <string, object> scoreDic = (Dictionary <string, object>)e.data;
            if ((int)scoreDic["newLevel"] > (int)scoreDic["oldLevel"])
            {
                this.addEffect("bangScore");
                this.doAvatarAnimation("score");
            }
        });

        this._playerEntity.addListener(EventConstant.KILL_PLAYER, (MainEvent e) => {
            List <ClientPlayerEntity> players = (List <ClientPlayerEntity>)e.data;
            this.scene.addKillRadio(players[0], players[1]);
        });

        this.gameObject.SetActive(this._fightEntity.alived);
    }