Example #1
0
 void Start()
 {
     //cm = GetComponent<CharacterMovement>();
     rpi    = GetComponent <RayPlayerInput>();
     rm     = GetComponent <RayMovement>();
     diagUI = FindObjectOfType <DialogueUI>();
 }
    private void SpawnRandomMeteorite()
    {
        Vector3     position          = spawnCenter + (spawnAxis * Random.Range(-(meteoriteSpawnSpread / 2), (meteoriteSpawnSpread / 2)));
        GameObject  meteoriteInstance = (GameObject)Instantiate(meteoritePrefab, position, Quaternion.identity);
        RayMovement rayMovement       = meteoriteInstance.GetComponent <RayMovement>();

        rayMovement.direction = direction;
        spawned++;
    }
Example #3
0
 void Start()
 {
     //hivemind = FindObjectOfType<AdvancedHivemind>();
     if (targetChar)
     {
         rc = targetChar.GetComponent <RandomComment>();
         rm = targetChar.GetComponent <RayMovement>();
         //targetChar.GetComponent<RayNPC>().enableSimpleAI = false;
     }
 }
    private void Fire()
    {
        lastFiringTime = Time.time;
        GameObject  bulletInstance = (GameObject)Instantiate(bulletPrefab, transform.position, Quaternion.identity);
        RayMovement rayMovement    = bulletInstance.GetComponent <RayMovement>();

        rayMovement.direction   = (centerPosition - transform.position).normalized;
        rayMovement.maxDistance = currentDistance;
        rayMovement.offset      = 0f;
    }
Example #5
0
    /// <summary>
    /// Casts a ray to see if we hit an NPC and, if so, we interact
    /// </summary>
    void TryInteract()
    {
        if (discussionPartner)
        {
            DoInteraction();
            return;
        }

        // Multi ray
        RaycastHit2D[] rHit = Physics2D.RaycastAll(new Vector2(transform.position.x, transform.position.y + 3), Vector2.right * rm.facingDirection, reachDistance, -1);
        if (rHit.Length > 0)
        {
            foreach (RaycastHit2D hit in rHit)
            {
                if (hit.collider.tag == "NPC")
                {
                    // Check for a ghost object
                    if (hit.collider.name.StartsWith("Ghost"))
                    {
                        // Get the ghost's original from the character pair list - not needed if ghost is original's child
                        //CharacterPair cp = FindObjectOfType<GhostManager>().characters.Find(c => c.Ghost == hit.collider.gameObject);

                        discussionPartner = hit.collider.transform.parent.gameObject;
                    }
                    else
                    {
                        discussionPartner = hit.collider.gameObject;
                    }

                    if (!discussionPartner.GetComponent <VIDE_Assign>())
                    {
                        return;
                    }

                    discussionPartnerRM   = discussionPartner.GetComponent <RayMovement>();
                    discussionPartnerRNPC = discussionPartner.GetComponent <RayNPC>();
                    isControlledNPC       = discussionPartner.GetComponent <NPCControl>();

                    discussionPartnerRM.allowMovement = false;
                    discussionPartnerRM.FaceTarget(GetComponentInChildren <SpriteRenderer>());
                    discussionPartnerRNPC.SetAIBehaviourActive(false);

                    DoInteraction();

                    // Break the loop so that only one conversation is active in case many NPC's got raycasted
                    break;
                }
            }
        }
    }
Example #6
0
    // Use this for initialization
    void Start()
    {
        if (!sporeShotSource)
        {
            sporeShotSource = transform.FindChild("SporeShotSource").gameObject;
        }

        rayMovement          = GetComponent <RayMovement>();
        characterInteraction = GetComponent <CharacterInteraction>();

        ui = GameObject.FindGameObjectWithTag("UI");
        triggerIndicator = ui.transform.FindChild("TriggerIndicator").gameObject;

        cameras = FindObjectOfType <CameraController>();
    }
Example #7
0
    /// <summary>
    /// Activates/deactivates dialogue mode.
    /// </summary>
    /// <param name="active">Active state wanted.</param>
    public void SetDialogueModeActive(bool active)
    {
        CharacterManager.GetCurrentCharacterObject().GetComponent <RayMovement>().allowMovement        = !active;
        CharacterManager.GetCurrentCharacterObject().GetComponent <RayPlayerInput>().enablePlayerInput = !active;

        RayMovement partnerRM   = discussionPartner.GetComponent <RayMovement>();
        RayNPC      partnerRNPC = discussionPartner.GetComponent <RayNPC>();

        partnerRM.allowMovement = !active;
        partnerRNPC.SetAIBehaviourActive(!active);

        if (active)
        {
            partnerRM.FaceTarget(CharacterManager.GetCurrentCharacterObject().GetComponentInChildren <SpriteRenderer>());
        }
        if (!active && dialogueUI.dialogue.isLoaded)
        {
            dialogueUI.dialogue.EndDialogue();
            discussionPartner = null;
        }
    }
Example #8
0
 private void Awake()
 {
     rayMovement = GetComponent <RayMovement>();
 }
Example #9
0
    void Update()
    {
        if (Input.GetKeyDown(keyKillCurrentCharacter))
        {
            //hivemind.RemoveCharacter(hivemind.GetCurrentlyActiveCharacter());
            CharacterManager.KillCharacter(CharacterManager.GetCurrentCharacterEntity());
        }

        if (targetChar)
        {
            if (Input.GetKeyDown(keyWarpTargetToCurrent))
            {
                WarpTargetToCurrent();
            }

            if (Input.GetKeyDown(keyChangeCommentOfTargetChar))
            {
                if (!rc)
                {
                    rc = targetChar.GetComponentInChildren <RandomComment>(true);
                }

                commentNum++;
                if (commentNum >= rc.GetCommentCount())
                {
                    commentNum = 0;
                }
                rc.GetComment(commentNum);
            }

            if (Input.GetKey(keyMoveTargetCharLeft))
            {
                dir = -1;
            }
            else if (Input.GetKey(keyMoveTargetCharRight))
            {
                dir = 1;
            }
            else
            {
                dir = 0;
            }

            if (dir != 0)
            {
                if (targetChar.GetComponent <RayNPC>().enableSimpleAI)
                {
                    targetChar.GetComponent <RayNPC>().enableSimpleAI = false;
                }
            }

            if (!targetChar.GetComponent <RayNPC>().enableSimpleAI)
            {
                rm.CharacterInput = new Vector2(dir, 0);
                rm.Run            = Input.GetKey(keyRunWithTargetChar);
            }
        }
        else
        {
            targetChar = CharacterManager.instance.allCharacters[Random.Range(1, CharacterManager.instance.allCharacters.Count)].GetGameObject();
            if (targetChar)
            {
                rc = targetChar.GetComponent <RandomComment>();
                rm = targetChar.GetComponent <RayMovement>();
            }
        }

        if (Input.GetKeyDown(keySpawnRandomCharacter))
        {
            if (listOfCharacters.allCharacters.Count > 0)
            {
                SpawnRandomCharacter(true);
            }
        }

        if (Input.GetKeyDown(keySpawnRandomCharacterSomewhere))
        {
            if (listOfCharacters.allCharacters.Count > 0)
            {
                SpawnRandomCharacter(false);
            }
        }

        float delta = Input.GetAxisRaw("Mouse ScrollWheel");

        if (delta != 0 && allowCameraZoom)
        {
            FindObjectOfType <CameraController>().ChangeZoomLevelInstant(-delta);
        }
    }
Example #10
0
    private void Awake()
    {
        rayMovement = GetComponent <RayMovement>();

        //InvokeRepeating("StateRandomization", 1, 1);
    }