Beispiel #1
0
        public bool isWaterSurfaceOnScreen()
        {
            if (!cameraFollow)
            {
                cameraFollow = Camera.main.GetComponent <cameraFollowPlayer>();
            }
            if (!cameraFollow)
            {
                return(true);
            }
            float cl = cameraFollow.getLeftViewX() - 1f;
            float cr = cameraFollow.getRightViewX() + 1f;
            float ct = cameraFollow.getTopViewY() + 1f;
            float cb = cameraFollow.getBottomViewY() - 1f;

            Rect cam = new Rect(cl, cb, cr - cl, ct - cb);

            if (cam.Overlaps(new Rect(bound.left, bound.top, bound.right, bound.top + 1f)))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
    //This function spawns a projectile based on all of the projectile settings. Typically called from useItemAction
    public void spawnProjectile()
    {
        if (!spawnProjectilePrefab)
        {
            return;
        }
        Vector3 spawnPos;

        if (hasActionAim)
        {
            spawnPos = gameObject.transform.position + actionAimArc.getPointAlongAngle(spawnProjectileDistance) + (Vector3)offset + (Vector3)spawnProjectileOffset;
        }
        else
        {
            spawnPos    = gameObject.transform.position + (Vector3)offset + (Vector3)spawnProjectileOffset;
            spawnPos.x += spawnProjectileDistance * (flippedX ? -1 : 1);
        }
        GameObject projectile = Instantiate(spawnProjectilePrefab, spawnPos, Quaternion.identity);

        if (sceneSettingsGO != null)
        {
            sceneSettingsGO.objectCreated(projectile);
        }
        GameObject particles = null;

        if (spawnProjectileParticles)
        {
            particles = Instantiate(spawnProjectileParticles, spawnPos, Quaternion.identity);
        }
        if (setProjectileRotation && hasActionAim)
        {
            projectile.transform.eulerAngles = new Vector3(0f, 0f, actionAimArc.angle);
        }
        if (setParticleRotation && hasActionAim && particles)
        {
            particles.transform.eulerAngles = new Vector3(0f, 0f, actionAimArc.angle);
        }

        if (playerControlledProjectile && spawnProjectileBehavior != spawnProjectileBehaviors.spawnWhileHeld && holder != null)
        {
            projectile.SendMessage("initiatePlayerControl", holder, SendMessageOptions.DontRequireReceiver);
        }

        if (projectileCamshakeDuration != 0 && projectileCamshakeIntensity != 0)
        {
            cameraFollowPlayer cfp = Camera.main.GetComponent <cameraFollowPlayer>();
            if (cfp)
            {
                cfp.TriggerShakeExt(projectileCamshakeIntensity, projectileCamshakeDuration);
            }
        }

        if (sndSpawnProjectile)
        {
            global.audio.Play(sndSpawnProjectile);
        }
    }
    // Initialization
    void Start()
    {
        // Set the turnLenght
        turnLenght = 18;

        // Set the first turn to true
        firstTurn = true;

        // Populate the game objects for cosmonauts and maraptors
        Cosmonauts.AddRange(GameObject.FindGameObjectsWithTag("Cosmonaut"));
        Maraptors.AddRange(GameObject.FindGameObjectsWithTag("Maraptor"));

        // Populate the State Machines for cosmonauts and maraptors, editing their names and startup properites
        foreach (GameObject Cosmonaut in Cosmonauts)
        {
            cosmonautP            = Cosmonaut.GetComponent <cosmonautBase> ();
            cosmonautP.name       = Cosmonaut.transform.gameObject.name;
            cosmonautP.baseHP     = 100;
            cosmonautP.currentHP  = 100;
            cosmonautP.baseShield = 50;
            CosmonautStateMachines.Add(Cosmonaut.GetComponent <cosmonautStateMachine> ());
        }
        foreach (GameObject Maraptor in Maraptors)
        {
            maraptorP            = Maraptor.GetComponent <maraptorBase> ();
            maraptorP.name       = Maraptor.transform.gameObject.name;
            maraptorP.baseHP     = 100;
            maraptorP.currentHP  = 100;
            maraptorP.baseShield = 50;
            MaraptorStateMachines.Add(Maraptor.GetComponent <maraptorStateMachine> ());
        }

        // Get the numberOfCosmonauts and numberOfMaraptors
        numberOfCosmonauts = Cosmonauts.Count;
        numberOfMaraptors  = Maraptors.Count;

        // Set the number of player characters and the number of played on characters
        numberOfPlayerCharacters   = numberOfCosmonauts + numberOfMaraptors;
        numberOfPlayedOnCharacters = 0;

        // Get the MainCameraPlayer
        MainCameraPlayer = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <cameraFollowPlayer> ();;

        // Get the Action Menu
        AM = GameObject.Find("ActionMenu").GetComponent <actionMenuScript>();

        // Start Game
        GameState = GameStateEnum.INTRO;
        turnTimer = 0;
        StartCoroutine("TurnTimerIncrementor");
    }
Beispiel #4
0
    // Start is called before the first frame update
    void Start()
    {
        view = Camera.main.GetComponent <cameraFollowPlayer>() as cameraFollowPlayer;
        if (conversationCenterPoint == null)
        {
            conversationCenterPoint = gameObject.transform;
        }

        characterController = gameObject.GetComponent <CharacterController2D>() as CharacterController2D;
        currentGroup        = startGroup;
        if (myType == type.AutoGroup || myType == type.AutoGroupLoop || myType == type.AutoRandom || myType == type.AutoStraightshot || myType == type.AutoStraightshotLoop)
        {
            isAutoType = true;
            if (autoInitiateAtStart)
            {
                Initiate();
            }
        }
    }
Beispiel #5
0
    void Awake()
    {
        global = GameObject.FindWithTag("global").GetComponent <Global>();

        if (dialogCanvasPrefab)
        {
            canvas = Instantiate(dialogCanvasPrefab);
        }
        else //Assets/Resources/PrefabsAndScripts/MenusAndDialogs/Dialog/DialogCanvas.prefab
        {
            canvas = Instantiate(Resources.Load <GameObject>(global.dirDialogSystem + "DialogCanvas"));
        }

        canvasGroup     = canvas.GetComponent <CanvasGroup>() as CanvasGroup;
        canvasComponent = canvas.GetComponent <Canvas>() as Canvas;
        canvas.SetActive(false); //We don't want to enable the canvas until after the firt OnGui event completes. This prevents some glitchy looking artifacts.
        dBox   = canvas.transform.Find("dBox").gameObject;
        bg     = dBox.transform.Find("bg").gameObject;
        bgRect = bg.GetComponent <RectTransform>() as RectTransform;

        playerCam = Camera.main.GetComponent <cameraFollowPlayer>() as cameraFollowPlayer;
    }
Beispiel #6
0
    //Plays a sound effect if the specified position is within the camera's view. If cameraFollowPlayer does not exist then it will play the sound every time.
    //Buffer is added to the boundaries of the camera so pos can be a little outside of the view (negative buffer) or needs to be a little inside of the view (positive buffer)
    //By default the pos can be within one unit ouside of the view and the sound will still play.
    public void PlayIfOnScreen(AudioClip clip, Vector2 pos, float buffer = -1f, float randomizePitchMin = 1, float randomizePitchMax = 1)
    {
        if (!cameraFollow)
        {
            cameraFollow = Camera.main.GetComponent <cameraFollowPlayer>();
        }

        bool play = true;

        if (cameraFollow)
        {
            if (!cameraFollow.insideView(pos, buffer, buffer))
            {
                play = false;
            }
        }

        if (play)
        {
            Play(clip, randomizePitchMin, randomizePitchMax);
        }
    }
Beispiel #7
0
        private void Start()
        {
            global = GameObject.FindWithTag("global").GetComponent <Global>();
            if (!cameraFollow)
            {
                cameraFollow = Camera.main.GetComponent <cameraFollowPlayer>();
            }

            bEffectorOne = GetComponent <BuoyancyEffector2D>() as BuoyancyEffector2D;
            if (buoyancyEffectorTwoGo != null)
            {
                bEffectorTwo = buoyancyEffectorTwoGo.GetComponent <BuoyancyEffector2D>() as BuoyancyEffector2D;
            }

            if (noInitialSplash)
            {
                canSplash = false;
                Invoke("initialSplashSwitch", 0.1f);
            }
            Reset();

            InvokeRepeating("UpdateSurface", 0.0f, 1.0f / sampleRate);
        }
Beispiel #8
0
 void Start()
 {
     camScript = FindObjectOfType <cameraFollowPlayer>();
 }