示例#1
0
        protected IObjRef ResolveObjRefOfCache(IObjRef objRef, CloneState cloneState)
        {
            StateEntry stateEntry = cloneState.incrementalState.objRefToStateMap.Get(objRef);

            if (stateEntry != null)
            {
                return(stateEntry.objRef);
            }
            stateEntry = cloneState.newObjRefToStateEntryMap.Get(objRef);
            if (stateEntry != null)
            {
                return(stateEntry.objRef);
            }
            return(objRef);
        }
        public SelectionToolPanel(Action <BasicSurface> loadBrushHandler, Func <BasicSurface> saveBrushHandler)
        {
            reset        = new Button(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls);
            reset.Text   = "Reset Steps";
            reset.Click += (o, e) => State = CloneState.SelectingPoint1;

            loadBrush        = new Button(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls);
            loadBrush.Text   = "Import Brush";
            loadBrush.Click += _loadBrush_Click;

            saveBrush        = new Button(SadConsoleEditor.Consoles.ToolPane.PanelWidthControls);
            saveBrush.Text   = "Export Brush";
            saveBrush.Click += _saveBrush_Click;

            clone        = new Button(Consoles.ToolPane.PanelWidthControls);
            clone.Text   = "Clone";
            clone.Click += clone_Click;

            clear        = new Button(Consoles.ToolPane.PanelWidthControls);
            clear.Text   = "Clear";
            clear.Click += clear_Click;

            move        = new Button(Consoles.ToolPane.PanelWidthControls);
            move.Text   = "Move";
            move.Click += move_Click;



            Controls = new ControlBase[] { reset, loadBrush, saveBrush, clone, clear, move };

            this.loadBrushHandler = loadBrushHandler;
            this.saveBrushHandler = saveBrushHandler;

            Title = "Clone";
            State = CloneState.SelectingPoint1;
        }
 private void move_ButtonClicked(object sender, EventArgs e)
 {
     State = CloneState.Move;
 }
 private void clone_ButtonClicked(object sender, EventArgs e)
 {
     State = CloneState.Clone;
 }
 private void clone_Click(object sender, EventArgs e)
 {
     State = CloneState.Stamp;
 }
 private void clear_Click(object sender, EventArgs e)
 {
     State = CloneState.Clear;
 }
 private void move_Click(object sender, EventArgs e)
 {
     State = CloneState.Move;
 }
 void StopClone()
 {
     GameEvents.current.onWin      -= StopClone;
     GameEvents.current.onGameOver -= StopClone;
     state = CloneState.STOPPED;
 }
    private void Update()
    {
        if (state == CloneState.STOPPED)
        {
            return;
        }
        if (inFieldOfVision)
        {
            bool nextState = CanSeePlayer();
            if (nextState == false && spotted == true)
            {
                t     = 0;
                state = CloneState.RETURNINGTOWALK;
            }
            else if (nextState == true && spotted == false)
            {
                t     = 0;
                state = CloneState.TURNINGTOPLAYER;
            }
            spotted = nextState;
        }
        else if (state != CloneState.WANDERING && state != CloneState.RETURNINGTOWALK)
        {
            t     = 0;
            state = CloneState.RETURNINGTOWALK;
        }


        if (state == CloneState.WANDERING)
        {
            // rotate back to look
            if (pointsInTime.Count - 1 > posIndex)
            {
                //Debug.Log("initial" + pointsInTime[posIndex].rotation);
                //Debug.Log("next" + pointsInTime[posIndex+1].rotation);
                t += Time.deltaTime / posUpdateTime;
                Vector3 move = Vector3.Lerp(pointsInTime[posIndex].position, pointsInTime[posIndex + 1].position, t);
                float   diff = (move - transform.position).sqrMagnitude;
                if (diff == 0f && walkingSound.isPlaying)
                {
                    walkingSound.Stop();
                }
                else if (diff > 0f && !walkingSound.isPlaying)
                {
                    walkingSound.Play();
                }
                transform.position = move;
                transform.rotation = Quaternion.Slerp(pointsInTime[posIndex].rotation, pointsInTime[posIndex + 1].rotation, t);
                lastRot            = transform.rotation;
                lastLerpT          = t;
                // Debug.Log(lastPosition);
                if (t > 1)
                {
                    t         = 0;
                    posIndex += 1;
                }
            }
        }
        else if (state == CloneState.TURNINGTOPLAYER)
        {
            Quaternion currentRot = transform.rotation;
            Quaternion newRot     = Quaternion.LookRotation(playerPos.position -
                                                            transform.position, transform.TransformDirection(Vector3.up));
            if (t < 1f)
            {
                t += Time.deltaTime;
                transform.rotation =
                    Quaternion.Lerp(currentRot, newRot, t / 1f);
            }
            else
            {
                t     = 0;
                state = CloneState.LOOKINGATPLAYER;
            }
        }
        else if (state == CloneState.LOOKINGATPLAYER)
        {
            t = 0;
            transform.LookAt(playerPos.position);
        }
        else if (state == CloneState.RETURNINGTOWALK)
        {
            Quaternion currentRot = transform.rotation;
            if (t < 1f && currentRot != lastRot)
            {
                t += Time.deltaTime;
                transform.rotation =
                    Quaternion.Slerp(currentRot, lastRot, Time.deltaTime * 5f);
            }
            else
            {
                t     = lastLerpT;
                state = CloneState.WANDERING;
            }
        }

        if (state != CloneState.WANDERING)
        {
            walkingSound.Stop();
            animator.SetBool("isIdle", true);
        }
        else
        {
            animator.SetBool("isIdle", false);
        }

        if (state == CloneState.LOOKINGATPLAYER)
        {
            if (spottedTime == 0f)
            {
                GameEvents.current.PlayerSpotted();
            }
            DISystem.CreateIndicator(transform);

            if (spottedTime > 3f)
            {
                Debug.Log("Game over");
                GameEvents.current.GameOver();
                state = CloneState.STOPPED;
            }
            spottedTime += Time.deltaTime;
        }
        else
        {
            spottedTime = 0f;
            GameEvents.current.PlayerSafe();
        }
    }
示例#10
0
        protected IObjRef CloneObjRef(IObjRef original, bool fromChangeContainer)
        {
            CloneState cloneState = cloneStateTL.Value;

            return(ResolveObjRefOfCache(original, cloneState));
        }