Exemplo n.º 1
0
    // Use this for initialization
    void Awake()
    {
        // First, set barScaleFactor such that the height of the health bars is the upper 20% of the screen.
        barScaleFactor = (0.2f * Screen.height) / barTextureHeight;

        // 793 x 289 is the scale for the health bar png.
        barTextureLength *= barScaleFactor;
        barTextureHeight *= barScaleFactor;

        xOffset = (int) (0.3f * barTextureLength);
        yOffsetHealth = (int) (0.35f * barTextureHeight);
        yOffsetSpecial = (int) (0.5f * barTextureHeight);

        // Initialize character attributes
        charCombat = character.GetComponent<CombatScript> ();
        charMover = character.GetComponent<MovementAnimationScript> ();
        startHealth = charCombat.startHealth;
        charOnLeft = !charMover.facingLeft;

        // Initialize special attack strength.
        maxSpecialStrength = charCombat.maxSpecialStrength;

        // The health bar will be flipped and shifted from the left side of the screen
        // if the character's position is on the right.
        if (!charOnLeft){
            float spaceFromLeft = (float) (1f - (1.02 * (barTextureLength/Screen.width)));
            barPosition = Camera.main.ViewportToScreenPoint( new Vector3( spaceFromLeft, 0.01f, 0f) );

        } else {
            barPosition = Camera.main.ViewportToScreenPoint( new Vector3(0f, 0.01f, 0f) );
        }
        //		Debug.Log (gameObject + "'s barPosition is: " + barPosition);
        //		Debug.Log ("The bar length and height for " + gameObject + " are: " + barTextureLength + " and " + barTextureHeight);
    }
Exemplo n.º 2
0
 // Start is called before the first frame update
 void Start()
 {
     move_script      = GetComponent <movePlayer>();
     combat_script    = GetComponent <CombatScript>();
     inventory_script = GetComponent <InventoryScript>();
     grab_script      = GetComponent <GrabScript>();
 }
Exemplo n.º 3
0
    public void init(int number, CombatScript cs)
    {
        this.number = number;
        this.units  = new List <CombatUnit>(3);

        CombatUnit archer;

        CombatUnit knight;

        CombatUnit soldier;

        if (number == 1)
        {
            archer  = cs.blues[0].AddComponent <CombatUnit>();
            knight  = cs.blues[1].AddComponent <CombatUnit>();
            soldier = cs.blues[2].AddComponent <CombatUnit>();
        }
        else
        {
            archer  = cs.reds[0].AddComponent <CombatUnit>();
            knight  = cs.reds[1].AddComponent <CombatUnit>();
            soldier = cs.reds[2].AddComponent <CombatUnit>();
        }


        archer.init(this.number, 1);
        knight.init(this.number, 2);
        soldier.init(this.number, 3);
        this.units.Add(archer);
        this.units.Add(knight);
        this.units.Add(soldier);
    }
 //    MovementAnimationScript parentMover;
 // Use this for initialization
 void Start()
 {
     Physics2D.IgnoreLayerCollision (11, 11);
     Physics2D.IgnoreLayerCollision (12, 12);
     parentChar = GameObject.Find (characterName);
     parentCombat = parentChar.GetComponent<CombatScript> ();
     //		parentMover = parentChar.GetComponent<MovementAnimationScript> ();
 }
Exemplo n.º 5
0
 public void Quit()
 {
     Destroy(GameObject.Find("UI"));
     GameLevelManager.resetScore();
     CombatScript.resetHeroLife();
     PlayMusic.StopMusic();
     SceneManager.LoadScene("MainMenu");
     Pause.UnPause();
 }
Exemplo n.º 6
0
 void Start()
 {
     script = GameObject.FindGameObjectWithTag("Player").GetComponentInChildren <CombatScript> ();
     if (gameObject.name == "HeadHitBox")
     {
         hitDamage = hitDamage * 6;
     }
     Debug.Log(hitDamage + " " + gameObject.name);
 }
Exemplo n.º 7
0
    private void Start()
    {
        move_script   = GetComponent <movePlayer>();
        health_script = GetComponent <HealthScript>();
        combat_script = GetComponent <CombatScript>();

        consume_doener      = false;
        consume_frankfurter = false;
        consume_puntigamer  = false;
    }
Exemplo n.º 8
0
 private void Awake()
 {
     if (instance != null)
     {
         Destroy(this.gameObject);
     }
     else
     {
         instance = this;
     }
 }
Exemplo n.º 9
0
    // Start is called before the first frame update
    void Start()
    {
        enemyDetection = GetComponentInChildren <EnemyDetection>();
        playerCombat   = FindObjectOfType <CombatScript>();
        skinMeshList   = GetComponentsInChildren <SkinnedMeshRenderer>();

        anim              = GetComponent <Animator>();
        swordOrigRot      = sword.localEulerAngles;
        swordOrigPos      = sword.localPosition;
        swordMesh         = sword.GetComponentInChildren <MeshRenderer>();
        swordMesh.enabled = false;
    }
Exemplo n.º 10
0
    void Update()
    {
        //Case where player is spawned via Game Manager
        if (playerCombat == null)
        {
            playerCombat = FindObjectOfType <CombatScript>();
        }
        //Constantly look at player
        transform.LookAt(new Vector3(playerCombat.transform.position.x, transform.position.y, playerCombat.transform.position.z));

        //Only moves if the direction is set
        MoveEnemy(moveDirection);
    }
Exemplo n.º 11
0
    private void Start()
    {
        turnBaseScript = TurnBaseScript.instance;
        eventSys       = EventSystem.current;
        combatScript   = CombatScript.instance;

        //Find all enemies; you can't get only the status script from them so there was a need for a workaround
        GameObject[] monsterAux = GameObject.FindGameObjectsWithTag("Enemy");
        enemyStatus = new Status[monsterAux.Length];
        for (int index = 0; index < monsterAux.Length; index++)
        {
            enemyStatus[index] = monsterAux[index].GetComponent <Status>();
        }
    }
Exemplo n.º 12
0
    private void Start()
    {
        //Initialize variables
        inventory      = Inventory.instance;
        eventSys       = EventSystem.current;
        combatScript   = CombatScript.instance;
        turnBaseScript = TurnBaseScript.instance;
        description    = descriptionTab.GetComponentInChildren <Text>();

        //Deactivate everything concerning this script (was useful when testing but wouldn't be too bad to keep them)
        //That is unless there are eficiency problems, in that case delete them but be careful that it doesn't mess up anything
        itemsParent.SetActive(false);
        descriptionTab.SetActive(false);
    }
Exemplo n.º 13
0
    void Start()
    {
        cs           = GetComponent <CombatScript>();
        playerObject = GetComponent <Transform>();
        Debug.Log(playerObject.position.x);
        inventory = new Inventory(this);
        //Placeholder Inventory
        for (int i = 0; i < inventorySize; i++)
        {
            Item item = Resources.Load <Item>("Items/Potion");

            inventory.addItem(item);
        }
    }
 void Awake()
 {
     //StartCoroutine(startTimeCount());
     //availableEnemies = new Transform[numberOfAvailableEnemies];
     //numberOfAvailableEnemies = availableEnemies.Length;
     Time.timeScale = 1f;
     PlayerHealthTextSize = new Vector2((Screen.width * 400) / 551, (Screen.height * 100) / 310);
     //enemiesInQueue = new int[numberOfLanes];
     //lanesOccupied = new bool[numberOfLanes];
     PlayerFont.fontSize = PlayerFont.fontSize * Screen.width/ 551;
     distanceBetweenLanes = obtainDistanceBetweenLanes();
     playerScript = player.GetComponentInChildren<CombatScript>();
     //Debug.Log("MinPos " + minPos + "\nMaxPos " + maxPos);
     //Debug.Log("Distance between lanes: " + distanceBetweenLanes);
 }
Exemplo n.º 15
0
    private void OnTriggerEnter(Collider other)
    {
        CombatScript combatScript = GameObject.Find("EventSystem").GetComponent <CombatScript>();

        if (other.tag == "Hero")
        {
            if (combatScript.getHeroLife() < 5)
            {
                combatScript.addHeroLife(1);
            }
            GameObject.Find("Hero").GetComponent <AudioSource>().PlayOneShot(drink);
            GameLevelManager.addScore(5);
            Destroy(this.gameObject);
        }
    }
Exemplo n.º 16
0
    void Start()
    {
        enemyManager = GetComponentInParent <EnemyManager>();

        animator            = GetComponent <Animator>();
        characterController = GetComponent <CharacterController>();

        playerCombat   = FindObjectOfType <CombatScript>();
        enemyDetection = playerCombat.GetComponentInChildren <EnemyDetection>();

        playerCombat.OnHit.AddListener((x) => OnPlayerHit(x));
        playerCombat.OnCounterAttack.AddListener((x) => OnPlayerCounter(x));
        playerCombat.OnTrajectory.AddListener((x) => OnPlayerTrajectory(x));

        MovementCoroutine = StartCoroutine(EnemyMovement());
    }
Exemplo n.º 17
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        ObstacleScript obstacle = collision.collider.GetComponent <ObstacleScript>();

        if (obstacle != null)
        {
            obstacle.TakeDamage(damage);
        }

        CombatScript disc = collision.collider.GetComponent <CombatScript>();

        if (disc != null)
        {
            disc.catchDisc();
            Destroy(gameObject);
        }
    }
Exemplo n.º 18
0
    private void Start()
    {
        // Initialize variables
        dataRetainer     = DataRetainer.instance;
        combatManager    = CombatScript.instance;
        combatStatistics = CombatStatistics.instance;
        enemyAI          = GetComponent <EnemyCombatAI>();

        characters   = FindObjectsOfType <Status>();
        turnWaitTime = new int[characters.Length];

        // Assign the default value to all locations in turnLayout
        for (int index = 0; index < turnLayout.Length; index++)
        {
            turnLayout[index] = -1;
        }

        DefaultInit();                              //Initialize the default turn layout
        StartCoroutine(ChangeTurnsWaitTime(0.5f));  //Start changing turns with delay
    }
Exemplo n.º 19
0
    void Start()
    {
        isTalkable    = npc.isTalkable;
        characterName = npc.characterName;
        characterAge  = npc.characterAge;
        isKeyNPC      = npc.isKeyNPC;
        isTalkable    = npc.isTalkable;
        isMerchant    = npc.isMerchant;
        hasQuests     = npc.hasQuests;
        faction       = npc.faction;
        speech        = GetComponent <NPCSpeechHolder>();
        sr            = GetComponent <SpriteRenderer>();
        polyNav       = GetComponent <PolyNav.PolyNavAgent>();
        rb            = GetComponent <Rigidbody2D>();
        cs            = GetComponent <CombatScript>();
        InitPosition();

        speed    = defaultSpeed;
        runSpeed = defaultRunSpeed;
    }
Exemplo n.º 20
0
 void Start()
 {
     navMeshRunner = GetComponent <NavMeshRunner> ();
     combatScript  = GetComponent <CombatScript> ();
 }
Exemplo n.º 21
0
    public List <NPCData> CollectCurrentData()
    {
        foreach (GameObject c in allNPCsInScene)
        {
            if (c.tag.ToString() != "NPC")
            {
                continue;
            }

            NPCData         temp = new NPCData();
            NPCInfo         a    = c.GetComponent <NPCInfo>();
            Stats           s    = c.GetComponent <Stats>();
            NPCSpeechHolder h    = c.GetComponent <NPCSpeechHolder>();
            CombatScript    cs   = c.GetComponent <CombatScript>();

            temp.x         = c.transform.position.x;
            temp.y         = c.transform.position.y;
            temp.direction = (int)a.direction;
            temp.state     = (int)a.state;

            temp.id       = a.id;
            temp.active   = c.gameObject.activeSelf;
            temp.canMove  = a.canMove;
            temp.inCombat = a.inCombat;
            if (cs.selectedSpell != null)
            {
                temp.selectedSpellID = cs.selectedSpell.ID;
            }
            else
            {
                temp.selectedSpellID = -1;
            }
            temp.castProgress   = cs.ProgressI;
            temp.combatState    = (int)cs.state;
            temp.energyState    = (int)cs.energyState;
            temp.currentHealth  = a.currentHealth;
            temp.currentStamina = a.currentStamina;
            temp.merchantMoney  = a.merchantMoney;
            temp.combatCooldown = a.combatCooldown;
            temp.cooldown       = a.timeStoppedCombat;
            temp.intuition      = s.intuition;
            temp.intelligence   = s.intelligence;
            temp.strength       = s.strength;
            temp.charisma       = s.charisma;
            temp.precision      = s.precision;
            temp.dexterity      = s.dexterity;
            temp.perception     = s.perception;
            temp.attitude       = s.attitude;
            temp.fear           = s.fear;
            temp.danger         = s.danger;
            temp.spirituality   = s.spirituality;
            temp.currentLine    = h.currentLine;
            temp.currentSet     = h.currentSet;
            temp.moveType       = (int)a.movementType;
            temp.areaPointX     = a.destination.x;
            temp.areaPointY     = a.destination.y;
            temp.isWaiting      = a.isWaiting;
            temp.isMoving       = a.isMoving;
            if (a.patrolPoints.Count > 0)
            {
                temp.hasPatrol    = true;
                temp.patrolPointX = a.patrolPoints[0].transform.position.x;
                temp.patrolPointY = a.patrolPoints[0].transform.position.y;
            }
            else
            {
                temp.hasPatrol    = false;
                temp.patrolPointX = 0;
                temp.patrolPointY = 0;
            }

            temp.inventory = new List <InventorySlotData>();
            foreach (Inventory.InventorySlot invSlot in a.merchantInventory.inventory)
            {
                InventorySlotData invSlotData = new InventorySlotData();
                invSlotData.id    = invSlot.item.ID;
                invSlotData.count = invSlot.count;
                temp.inventory.Add(invSlotData);
            }

            temp.maxSize = a.merchantInventory.maxSize;

            AddToData(temp);
        }
        return(allNPCData);
    }
Exemplo n.º 22
0
 private void Start()
 {
     movementInput = GetComponentInParent <ThirdPersonMovement>();
     combatScript  = GetComponentInParent <CombatScript>();
 }
Exemplo n.º 23
0
    public void ImportCombatHandlerData(CombatManagerData cmd)
    {
        foreach (GameObject h in allCombatHandlers)
        {
            Destroy(h);
        }
        allCombatHandlers.Clear();

        foreach (CombatHandlerData chd in cmd.chd)
        {
            GameObject    cHandler = Instantiate(combatHandler);
            CombatHandler ch       = cHandler.GetComponent <CombatHandler>();

            ch.wasLoaded = true;
            cHandler.transform.position = new Vector3(chd.posX, chd.posY, 0);
            ch.charactersInCombat       = new List <GameObject>();

            ch.currentCharactersTurn = new List <GameObject>();
            foreach (uint i in chd.currentCharactersTurn)
            {
                ch.currentCharactersTurn.Add(NPCManagerScript.ins.GetNPCInSceneFromID(i));
            }

            foreach (uint i in chd.charactersInCombat)
            {
                GameObject npc = NPCManagerScript.ins.GetNPCInSceneFromID(i);
                foreach (CharInfoInCombat info in chd.charactersInfoInCombat)
                {
                    if (info.ID == i)
                    {
                        CombatScript cs = npc.GetComponent <CombatScript>();
                        npc.GetComponent <CombatScript>().isReady = info.isReady;
                        npc.GetComponent <CombatScript>().endTurn = info.endTurn;
                        if (cs.turnCoroutine != null)
                        {
                            cs.StopTurnCoroutine();
                        }
                        if (!ch.currentCharactersTurn.Contains(npc))
                        {
                            npc.GetComponent <CombatScript>().StartWaiting(info.turnTimeOffset);
                        }
                        break;
                    }
                }
                ch.charactersInCombat.Add(npc);
            }

            ch.charactersChecked = new List <GameObject>();
            foreach (uint i in chd.charactersChecked)
            {
                ch.charactersChecked.Add(NPCManagerScript.ins.GetNPCInSceneFromID(i));
            }

            ch.charactersToCheck = new List <GameObject>();
            foreach (uint i in chd.charactersToCheck)
            {
                ch.charactersToCheck.Add(NPCManagerScript.ins.GetNPCInSceneFromID(i));
            }

            ch.charactersRemovedFromCombat = new List <GameObject>();
            foreach (uint i in chd.charactersRemovedFromCombat)
            {
                ch.charactersRemovedFromCombat.Add(NPCManagerScript.ins.GetNPCInSceneFromID(i));
            }
            if (ch.charactersInCombat.Contains(GameManagerScript.ins.player))
            {
                playerCombatHandler = cHandler;
            }


            allCombatHandlers.Add(cHandler);
        }

        ImportPlayerCombatData(cmd.pcd);
        Time.timeScale = cmd.timeScale;
    }
Exemplo n.º 24
0
    //IEnumerator lerp;

    private void Start()
    {
        combatScript = gameObject.GetComponent <CombatScript>();
    }
Exemplo n.º 25
0
 void Start()
 {
     move_script   = GetComponent <movePlayer>();
     health_script = GetComponent <HealthScript>();
     combat_script = GetComponent <CombatScript>();
 }
Exemplo n.º 26
0
 // Use this for initialization
 void Start()
 {
     combat = transform.root.GetComponent <CombatScript> ();
 }
Exemplo n.º 27
0
    public void LoadNPCSceneData(List <NPCData> apc)
    {
        allNPCData = apc;
        foreach (GameObject c in allNPCsInScene)
        {
            if (c.tag.ToString() != "NPC")
            {
                continue;
            }


            foreach (NPCData data in allNPCData)
            {
                if (c.GetComponent <NPCInfo>().id == data.id)
                {
                    NPCInfo         a  = c.GetComponent <NPCInfo>();
                    Stats           s  = c.GetComponent <Stats>();
                    NPCSpeechHolder h  = c.GetComponent <NPCSpeechHolder>();
                    CombatScript    cs = c.GetComponent <CombatScript>();

                    c.transform.position = new Vector3(data.x, data.y, 0);
                    a.UpdateColliders();
                    a.direction = (CharacterInfo.Direction)data.direction;
                    a.state     = (CharacterInfo.MovementState)data.state;


                    cs.ProgressI = data.castProgress;
                    if (data.selectedSpellID != -1)
                    {
                        cs.selectedSpell = SpellManagerScript.ins.GetSpellFromID(data.selectedSpellID);
                    }
                    else
                    {
                        if (cs.spellCoroutine != null)
                        {
                            cs.StopCoroutine(cs.spellCoroutine);
                        }
                    }
                    cs.state       = (CombatScript.CombatState)data.combatState;
                    cs.energyState = (CombatScript.EnergyState)data.energyState;

                    a.id = data.id;
                    a.gameObject.SetActive(data.active);
                    a.canMove = data.canMove;
                    if (a.inCombat)
                    {
                        cs.AIEndCombat();
                    }
                    else
                    {
                        a.EnterCombat();
                    }
                    a.inCombat = data.inCombat;
                    a.SetStoppingDistance();
                    a.currentHealth     = data.currentHealth;
                    a.currentStamina    = data.currentStamina;
                    a.merchantMoney     = data.merchantMoney;
                    a.combatCooldown    = data.combatCooldown;
                    a.timeStoppedCombat = data.cooldown;

                    s.intuition    = data.intuition;
                    s.intelligence = data.intelligence;
                    s.strength     = data.strength;
                    s.charisma     = data.charisma;
                    s.precision    = data.precision;
                    s.dexterity    = data.dexterity;
                    s.perception   = data.perception;
                    s.attitude     = data.attitude;
                    s.fear         = data.fear;
                    s.danger       = data.danger;
                    s.spirituality = data.spirituality;

                    h.currentLine = data.currentLine;
                    h.currentSet  = data.currentSet;

                    a.merchantInventory.maxSize = data.maxSize;

                    a.merchantInventory.ClearInventory();
                    foreach (InventorySlotData invSlotData in data.inventory)
                    {
                        a.merchantInventory.AddItemCount(ItemManagerScript.ins.GetItemFromID(invSlotData.id), invSlotData.count);
                    }

                    a.movementType = (NPC.MovementType)data.moveType;

                    a.destination = new Vector3(data.areaPointX, data.areaPointY, 0);

                    foreach (GameObject p in new List <GameObject>(a.patrolPoints))
                    {
                        if (p.transform.position.x != data.patrolPointX || p.transform.position.y != data.patrolPointY)
                        {
                            a.patrolPoints.Remove(p);
                            a.patrolPoints.Add(p);
                        }
                        else
                        {
                            if (!a.inCombat)
                            {
                                if (a.movementType == NPC.MovementType.PATROL)
                                {
                                    a.polyNav.SetDestination(a.patrolPoints[0].transform.position);
                                }
                            }
                            break;
                        }
                    }
                    if (a.isWaiting)
                    {
                        //a.polyNav.Stop();
                        if (a.waitCoroutine != null)
                        {
                            a.StopCoroutine(a.waitCoroutine);
                        }
                    }
                    a.isWaiting = data.isWaiting;
                    a.isMoving  = data.isMoving;
                    if (a.isWaiting)
                    {
                        a.polyNav.Stop();
                        switch (a.movementType)
                        {
                        case NPC.MovementType.AREA:
                            a.waitCoroutine = a.StartCoroutine(a.StartWaitingArea());
                            break;

                        case NPC.MovementType.PATROL:
                            a.waitCoroutine = a.StartCoroutine(a.StartWaitingPatrol());
                            break;

                        default:
                            break;
                        }
                    }
                    break;
                }
            }
        }
    }
Exemplo n.º 28
0
 void Awake()
 {
     _combat = GetComponent <CombatScript>();
 }