Пример #1
0
 public void Activate(PlayerBiped pc)
 {
     //Ability
     go = Instantiate(activatePrefab, pc.armMount.position, Quaternion.identity, pc.armMount);
     go.transform.localRotation = Quaternion.identity;
 }
Пример #2
0
    public void Trigger(Transform instigator)
    {
        if (transitioning)
        {
            return;
        }

        Entity check = instigator.GetComponent <Entity>();

        if (check != null)
        {
            bool OpenForThisCharacter = false;
            for (int i = 0; i < OpenForTeams.Length; i++)
            {
                if (OpenForTeams[i] == check.Team)
                {
                    OpenForThisCharacter = true;
                    break;
                }
            }
            if (!OpenForThisCharacter)
            {
                return;
            }
        }
        this.instigator = instigator;

        PlayerBiped player = instigator.GetComponentInParent <PlayerBiped>();

        if (player == null)
        {
            OpenAndClose(openDuration, null, null);
        }
        else
        {
            bool right = Vector3.Dot((transform.position - instigator.position).normalized, inside.right) > 0;
            if (MMXStyleDoorTransition)
            {
                animator.updateMode = AnimatorUpdateMode.UnscaledTime;
                Global.Pause();
                Global.instance.Controls.BipedActions.Disable();
                OpenAndClose(openDuration, delegate
                {
                    // open
                    SceneScript sceneScript = FindObjectOfType <SceneScript>();
                    if (sceneScript != null)
                    {
                        bool Entering = Vector3.Dot((inside.position - transform.position).normalized, (instigator.position - transform.position)) < 0;
                        if (Entering)
                        {
                            if (CameraIn != null)
                            {
                                Global.instance.AssignCameraZone(CameraIn);
                            }
                            else
                            {
                                Global.instance.AssignCameraZone(sceneScript.CameraZone);
                            }
                            if (Music != null)
                            {
                                Global.instance.MusicTransition(Music);
                            }
                        }
                        else
                        {
                            if (CameraOut != null)
                            {
                                Global.instance.AssignCameraZone(CameraOut);
                            }
                            else
                            {
                                Global.instance.AssignCameraZone(sceneScript.CameraZone);
                            }
                            if (Music != null)
                            {
                                Global.instance.MusicTransition(sceneScript.music);
                            }
                        }
                    }
                    // todo make door less awful
                    player.DoorTransition(right, openDuration, doorRunDistance);
                },
                             delegate
                {
                    // close
                    Global.instance.Controls.BipedActions.Enable();
                    Global.Unpause();
                });
            }
            else
            {
                bool Entering = Vector3.Dot((inside.position - transform.position).normalized, (instigator.position - transform.position)) < 0;
                if (((Entering && CameraIn != null) || (!Entering && CameraOut)))
                {
                    Global.instance.Controls.BipedActions.Disable();
                }
                OpenAndClose(openDuration, delegate
                {
                    if (Entering)
                    {
                        if (CameraIn != null)
                        {
                            Global.instance.AssignCameraZone(CameraIn);
                            runTimer.Start(runDuration, delegate
                            {
                                if (right)
                                {
                                    player.ApplyInput(new InputState {
                                        MoveRight = true
                                    });
                                }
                                else
                                {
                                    player.ApplyInput(new InputState {
                                        MoveLeft = true
                                    });
                                }
                            }, delegate
                            {
                                Global.instance.Controls.BipedActions.Enable();
                            });
                        }
                        else
                        {
                            SceneScript sceneScript = FindObjectOfType <SceneScript>();
                            if (sceneScript != null)
                            {
                                Global.instance.AssignCameraZone(sceneScript.CameraZone);
                            }
                        }
                    }
                    else
                    {
                        if (CameraOut != null)
                        {
                            Global.instance.AssignCameraZone(CameraOut);
                            runTimer.Start(runDuration, delegate
                            {
                                if (right)
                                {
                                    player.ApplyInput(new InputState {
                                        MoveRight = true
                                    });
                                }
                                else
                                {
                                    player.ApplyInput(new InputState {
                                        MoveLeft = true
                                    });
                                }
                            }, delegate
                            {
                                Global.instance.Controls.BipedActions.Enable();
                            });
                        }
                        else
                        {
                            SceneScript sceneScript = FindObjectOfType <SceneScript>();
                            if (sceneScript != null)
                            {
                                Global.instance.AssignCameraZone(sceneScript.CameraZone);
                            }
                        }
                    }
                }, null);
            }
        }
    }