public virtual void CreateGhost()
        {
            SetGhosted(false);

            var g = new GhostObject();
            g.SetParent(this);
            SetGhost(g);

            //GhostingManager.Instance.CreateGhost(this, g, EnumGhostType.GObject);

            SetGhosted(true);
        }
Beispiel #2
0
    public static void InterpolatePos(GhostObject owner)
    {
        float l2 = owner.mount0interp / OmniWorld.networkRate;
        float l3 = owner.mount1interp / OmniWorld.networkRate;
        float l5 = owner.mount2interp / OmniWorld.networkRate;
        float l4 = owner.rotCounter / OmniWorld.networkRate;

        if (l2 > 1)
            l2 = 1;
        if (l3 > 1)
            l3 = 1;
        if (l4 > 1)
            l4 = 1;
        if (l5 > 1)
            l5 = 1;

        float mount0lerp = Mathf.Lerp(owner.mount0ghostLast, owner.mount0ghostTime, l2);
        float mount1lerp = Mathf.Lerp(owner.mount1ghostLast, owner.mount0ghostTime, l3);
        float mount2lerp = Mathf.Lerp(owner.mount2ghostLast, owner.mount2ghostTime, l5);
        float rotlerp = Mathf.Lerp(owner.lastRot, owner.currentRot, l4);

        owner.owner.mount0time = mount0lerp;
        owner.owner.mount1time = mount1lerp;
        owner.owner.mount2time = mount2lerp;
        owner.owner.rotation = rotlerp;

        if (owner.currentRot == 0)
            owner.owner.rotation = 0;

        if (owner.owner.item.animList[0].animationType == OmniAnimation.Type.Skeleton)
        {
            for (int i = 0; i < OmniAnimation.Max_Skeletons; i++)
            {
                float l6 = owner.skelCounter[i] / OmniWorld.networkRate;
                if (l6 > 1)
                    l6 = 1;

                float skelLerp = Mathf.LerpAngle(owner.skelLast[i], owner.skelInterp[i], l6);
                if (i < owner.owner.skeleton.Length)
                    owner.owner.skeleton[i].rotation = skelLerp;

            }
        }
    }
    void Update()
    {
        if (!photonView.isMine) {
            return;
        }
        isDead =currentPawn==null||currentPawn.isDead;

        if(isDead){

            Pawn[] prefabClass=	PlayerManager.instance.avaiblePawn;

            respawnTimer-=Time.deltaTime;
            if(respawnTimer<=0&&isStarted){
                respawnTimer=respawnTime;
                currentPawn =PlayerManager.instance.SpawmPlayer(prefabClass[selected],team);
                PVPGameRule.instance.Spawn(team);
                AfterSpawnSetting(currentPawn,PawnType.PAWN,team);
                prefabBot =PlayerManager.instance.avaibleBots[selectedBot];
                prefabGhostBot =PlayerManager.instance.ghostsBots[selectedBot];

            }
        }else{
            Ray centerofScreen =Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f));
            RaycastHit hitinfo;
            if(robotPawn==null){
                robotTimer-=Time.deltaTime;

                if(robotTimer<=0){
                    if(Input.GetButton("SpawnBot")){

                        if(Physics.Raycast(centerofScreen, out hitinfo,50.0f)){
                            if(ghostBot==null){
                                GameObject ghostGameObj = Instantiate(prefabGhostBot,hitinfo.point,currentPawn.transform.rotation) as GameObject;
                                ghostBot =ghostGameObj.GetComponent<GhostObject>();
                            }
                            ghostBot.myTransform.position = hitinfo.point;
                            ghostBot.myTransform.rotation = currentPawn.transform.rotation;

                            if(Physics.SphereCast(hitinfo.point+Vector3.up*ghostBot.size,ghostBot.size,Vector3.up,out hitinfo,100.0f)){
                                //Debug.Log (hitinfo.collider);
                                if(canSpawnBot){
                                    ghostBot.MakeBad();
                                    //Debug.Log (ghostBot.myRenderer.sharedMaterial.color);
                                }
                                canSpawnBot=false;
                            }else{
                                if(!canSpawnBot){

                                    ghostBot.MakeNormal();
                                    //Debug.Log (ghostBot.myRenderer.sharedMaterial.color);
                                }
                                canSpawnBot=true;
                            }
                        }

                    }
                    if(Input.GetButtonUp("SpawnBot")){
                        if(ghostBot!=null&&canSpawnBot){
                            Vector3 spamPoint =ghostBot.transform.position;
                            spamPoint.y+= 10;
                            robotPawn =PlayerManager.instance.SpawmPlayer(prefabBot,spamPoint,ghostBot.transform.rotation);
                            //Debug.Log("robot spawn"+robotPawn);
                            AfterSpawnSetting(robotPawn,PawnType.BOT,team);

                            canSpawnBot=false;
                        }
                        //Debug.Log("destory chost");
                        Destroy(ghostBot.gameObject);
                    }

                }
            }

                if(inBot){
                    useTarget= null;
                    if(Input.GetButtonDown("Use")){
                        ExitBot();
                    }

                }else {

                        if(!inBot&&robotPawn!=null){
                            if(currentPawn.curLookTarget!=null&&currentPawn.curLookTarget.gameObject==robotPawn.gameObject){
                                if(Input.GetButtonDown("Use")){
                                    EnterBot();
                                }
                            }
                        }

                    if(currentPawn.curLookTarget!=null){

                        useTarget = currentPawn.curLookTarget.GetComponent<UseObject>();
                        if(useTarget!=null&&Input.GetButtonDown("Use")){
                            useTarget.Use(currentPawn);

                        }
                    }else{
                        useTarget= null;
                    }
                    //Debug.Log (currentPawn.curLookTarget);

                }
            if(Input.GetButtonDown("Fire2")){
                currentPawn.ToggleAim();
                if(robotPawn!=null){
                    robotPawn.ToggleAim();
                }
            }
            if(Input.GetButtonUp("Fire2")){
                currentPawn.ToggleAim();
                if(robotPawn!=null){
                    robotPawn.ToggleAim();
                }
            }
        }
    }
 public void SetGhost(GhostObject ghost)
 {
     GhostObject = ghost;
 }