Ejemplo n.º 1
0
    //This is called by our selectDialog using the Dialog.onCompletedCallback. It passes the name of the selected answer.
    public void itemSelected(string answer)
    {
        characterGo.SendMessage("Side", SendMessageOptions.DontRequireReceiver);

        if (type == types.dresserWithClothes)
        {
            if (canChangeColor && answer == changeColorString)
            {
                //Create a color picker and tell it to send us messages about it's state
                GameObject  cpo = Instantiate(colorPicker);
                ColorPicker cp  = cpo.GetComponent <ColorPicker>();
                cp.addMessageObject(gameObject);
                BlubberAnimation ba = characterGo.GetComponent <BlubberAnimation>();
                if (ba)
                {
                    cp.highlightColor(ba.getColor());
                }
            }
            else
            {
                if (answer == nakedString)
                {
                    characterGo.SendMessage("removeNonessentialDresses", SendMessageOptions.DontRequireReceiver);
                }

                DressObject d = dressList.Find(e => e.name == answer);
                if (d)
                {
                    characterGo.SendMessage("removeNonessentialDresses", SendMessageOptions.DontRequireReceiver);
                    GameObject     newDress      = Instantiate(d.gameObject, characterGo.transform);
                    SpriteRenderer dressRenderer = newDress.GetComponent <SpriteRenderer>() as SpriteRenderer;
                    dressRenderer.enabled = true;
                    characterGo.SendMessage("addDressObject", newDress, SendMessageOptions.DontRequireReceiver);
                    if (sceneSettingsGO != null)
                    {
                        sceneSettingsGO.objectCreated(newDress);
                    }
                }
                base.Close("", characterGo);
            }
        }

        if (type == types.spawnItemSelect)
        {
            int index = inventoryNames.IndexOf(answer);
            if (index != -1)
            {
                instantiateInventoryItem(index);
            }
            base.Close("", characterGo);
        }
    }
Ejemplo n.º 2
0
    //This callback is triggered when a scene has finished loading
    public void onSceneLoaded(Scene scene, LoadSceneMode mode)
    {
        boundary = GameObject.FindWithTag("sceneBoundary").GetComponent <sceneBoundary>() as sceneBoundary;

        if (instantiateOnLoadList.Count > 0)
        {
            foreach (instantiateOnLoadObject obj in instantiateOnLoadList)
            {
                if (obj.scene == "" || scene.name == obj.scene)
                {
                    obj.load();
                    settings.objectCreated(obj.go); //Notify the sceneSettings object
                }
            }
            instantiateOnLoadList.RemoveAll(obj => obj.loaded == true); //Remove all of the objects that were loaded
        }

        if (player != null)
        {
            repositionCharacterOnLoad();
            player.GetComponent <CharacterController2D>().sceneChangeComplete();
        }

        settings = GameObject.FindWithTag("SceneSettings").GetComponent <sceneSettings>() as sceneSettings;

        global.sceneChanging = false;
    }
Ejemplo n.º 3
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);
        }
    }
Ejemplo n.º 4
0
    void createSomething()
    {
        Vector3 p;

        if (createObjects[createSelection].createAtRearTransform)
        {
            p = (dir == 1 ? rightTransform.position : leftTransform.position);
        }
        else
        {
            p = (dir == 0 ? rightTransform.position : leftTransform.position);
        }

        GameObject go = Instantiate(createObjects[createSelection].obj, p, Quaternion.identity);

        if (sceneSettingsGO != null)
        {
            sceneSettingsGO.objectCreated(go);
        }
    }