Inheritance: MonoBehaviour
Beispiel #1
0
    protected override void ColourTiles()
    {
        if (MouseManager.Instance.mouseoveredTile == null)
        {
            return;
        }

        if (ShootingScript.WouldItBePossibleToShoot(myShootingScript, transform.position, MouseManager.Instance.mouseoveredTile.transform.position).Key == false)
        {
            return;
        }

        if (MouseManager.Instance.mouseoveredTile.myUnit != null)
        {
            MouseManager.Instance.mouseoveredTile.TCTool.ColourTile(Color.red);
        }
        else
        {
            MouseManager.Instance.mouseoveredTile.TCTool.ColourTile(Color.green);
        }
        foreach (Tile tile in MouseManager.Instance.mouseoveredTile.GetNeighbours())
        {
            if (tile.myUnit != null)
            {
                tile.TCTool.ColourTile(Color.red);
            }
            else
            {
                tile.TCTool.ColourTile(Color.green);
            }
        }
    }
Beispiel #2
0
 protected override void Start()
 {
     base.Start();
     m_minimaparrowAnimator  = UIManager.minimapArrow;
     thisEnemySetControl     = GetComponent <EnemySetControl>();
     thisEnemyShootingScript = GetComponent <ShootingScript>();
 }
Beispiel #3
0
    public override float EvaluateAsATarget(UnitScript currentUnit, Tile startingTile, Tile targetTile)
    {
        // here our shooter makes a decision of where to shoot at. He will:
        // 1. Want to hit guys with high "danger" to our units.
        // 2. Want to hit guys, who will give him more points
        // 3. Want to hit guys, who he has bigger chance to actually damage.

        ShootingScript shooter    = currentUnit.GetComponent <ShootingScript>();
        UnitScript     target     = targetTile.myUnit;
        float          Evaluation = 0f;

//        Debug.Log("Evaluating a shot by: " + currentUnit + " at: " + target);
        // 1.
        Evaluation += HowDangerousThisEnemyIs(target);

        // 2.
        Evaluation += target.Value * 0.1f;
        if (target.GetComponent <HeroScript>() != null)
        {
            Evaluation += 0.5f;
            // Thats just my ruff estimate of "value" of a hero here, lol.
        }
        // Debug.Log("Evaluation increased by: " + target.Value * 0.1f + " because of arget's value");
        // NOTE - this might want to get changed to "AI Value" when we add AIData scripts for units.

        // 3.
        float temp = ChancesToHit(currentUnit, shooter, target);

        Evaluation += temp;
        // Debug.Log("Evaluation increased by: " + temp + " for chances to hit");
        return(Evaluation);
    }
 void Start()
 {
     player          = GameObject.FindWithTag("Player");
     ShootActivation = player.GetComponent <ShootingScript>();
     SetQnA();
     InitBlocks();
 }
Beispiel #5
0
 // Use this for initialization
 void Start()
 {
     target         = GameObject.FindGameObjectWithTag("Player").transform;
     movement       = GetComponent <XYMovement>();
     shootingScript = GetComponent <ShootingScript>();
     fsm.pushState(WasteTime);
 }
Beispiel #6
0
    void RPCLaunchProjectile(int shooterX, int shooterZ, int targetX, int targetZ)
    {
        ShootingScript shooter = Map.Board[shooterX, shooterZ].myUnit.GetComponent <ShootingScript>();
        Vector3        target  = new Vector3(targetX, 0, targetZ);

        LaunchProjectile(shooter, target);
    }
Beispiel #7
0
    public static KeyValuePair <bool, bool> WouldItBePossibleToShoot(ShootingScript shooter, Vector3 start, Vector3 target)
    {
        Bounds FullRange = new Bounds(start, new Vector3(2 * shooter.currShootingRange + 0.25f, 5, 2 * shooter.currShootingRange + 0.25f));
        Bounds BadRange  = new Bounds(start, new Vector3(shooter.currShootingRange + 0.25f, 5, shooter.currShootingRange + 0.25f));
        bool   key       = false;

        if (shooter.currMinimalRange > 0)
        {
            Bounds miniRange = new Bounds(start, new Vector3(2 * shooter.currMinimalRange + 0.25f, 5, 2 * shooter.currMinimalRange + 0.25f));
            key = miniRange.Contains(target) == false && FullRange.Contains(target) && IsInLineOfSight(start, target, true);
        }
        else
        {
            key = FullRange.Contains(target) && IsInLineOfSight(start, target, true);
        }
        bool value;

        if (shooter.shortDistance)
        {
            value = (BadRange.Contains(target) == false);
        }
        else
        {
            value = false;
        }
        return(new KeyValuePair <bool, bool>(key, value));
    }
    public void ARUseRight()
    {
        GameObject     ARPLR       = GameObject.Find("arPlasmaLocationRight");
        ShootingScript shootScript = ARPLR.GetComponent <ShootingScript>();

        shootScript.ARShootRight();
        AudioSource.PlayClipAtPoint(ARShot, Camera.main.transform.position);
    }
Beispiel #9
0
 public void SetCurrentAbility(ShootingScript enemyShootingScript)                  //Aplicar pasiva a la variable de currentActiveAbility y al script de disparo/ataque
 {
     if (enemyPasiveAbility != AbilitiesSlotsManager.Instance.currentStoredAbility) //Si la pasiva no es igual que la almacenada, para avitar aplicarla en el enemigo que la setea
     {
         currentActiveAbility = AbilitiesSlotsManager.Instance.currentStoredAbility;
         enemyShootingScript.shSCR_PasiveAbility = currentActiveAbility;
     }
 }
Beispiel #10
0
 protected override bool ActivationRequirements()
 {
     return
         (MouseManager.Instance.mouseoveredTile != null &&
          MouseManager.Instance.mouseoveredTile.myUnit != null &&
          MouseManager.Instance.mouseoveredTile.myUnit.PlayerID != myUnit.PlayerID &&
          ShootingScript.WouldItBePossibleToShoot(this.GetComponent <ShootingScript>(), this.transform.position, MouseManager.Instance.mouseoveredTile.transform.position).Key);
 }
    public void SGUseRight()
    {
        GameObject     PLL         = GameObject.Find("sgPlasmaLocationRight");
        ShootingScript shootScript = PLL.GetComponent <ShootingScript>();

        shootScript.ShotgunShootRight();
        AudioSource.PlayClipAtPoint(ShotgunShot, Camera.main.transform.position);
    }
    public void pistolUseLeft()
    {
        GameObject     PLL         = GameObject.Find("plasmaLocationLeft");
        ShootingScript shootScript = PLL.GetComponent <ShootingScript>();

        shootScript.shootLeft();
        AudioSource.PlayClipAtPoint(pistolShot, Camera.main.transform.position);
    }
Beispiel #13
0
 void Start()
 {
     Btrf      = transform.GetChild(0);
     Ftrf      = transform.GetChild(1);
     RgBody2d  = GetComponent <Rigidbody2D>();
     weapon    = GetComponent <ShootingScript>();
     scaleStep = (transform.localScale.x / heath) / 2;
     newScale  = new Vector3(transform.localScale.x, transform.localScale.y, transform.localScale.z); // устанавливаем начальное значение
 }
Beispiel #14
0
 public void Start()
 {
     shootingScript = gameObject.GetComponent <ShootingScript>();
     ammoScript     = gameObject.GetComponent <AmmoScript>();
     bulletPool     = GameObject.Find("BulletPool").GetComponent <BulletPool>();
     character      = transform.Find("Character");
     GameManager.instance.playerStats  = transform.Find("StatsandSkills/PlayerStats").GetComponent <PlayerStats>();
     GameManager.instance.playerSkills = transform.Find("StatsandSkills/PlayerSkills").GetComponent <PlayerSkills>();
     speed = GameManager.instance.playerStats.movement.speed;
 }
Beispiel #15
0
 private void Start()
 {
     myUnit     = this.transform.root.GetComponent <UnitScript>();
     myShooting = this.transform.root.GetComponent <ShootingScript>();
     myHowler   = this.transform.root.GetComponent <Ability_Elves_Wolf_Howl>();
     mySwapper  = this.transform.root.GetComponent <Ability_Neutral_SwapWeapons>();
     myThrower  = this.transform.root.GetComponent <Ability_Elves_Assassin_DaggerThrow>();
     myCry      = this.transform.root.GetComponent <Ability_Hero_Knight_Battlecry>();
     myPikeman  = this.transform.root.GetComponent <Ability_Human_Pikeman_SpearBarricade>();
 }
    public void RPGUseRight()
    {
        GameObject     RRL         = GameObject.Find("RRLocation");
        ShootingScript shootScript = RRL.GetComponent <ShootingScript>();

        shootScript.RPGShootRight();
        //Dean is thrown back a bit when he fires the RPG
        deanAnderson.GetComponent <Rigidbody2D>().velocity = new Vector2(-5, 0);
        AudioSource.PlayClipAtPoint(RPGShot, Camera.main.transform.position);
    }
Beispiel #17
0
 protected override void ColourTiles()
 {
     foreach (Tile tile in Map.Board)
     {
         if (tile.hasObstacle && ShootingScript.WouldItBePossibleToShoot(myShootingScript, this.transform.position, tile.transform.position).Key&& Helper.FindChildWithTag(tile.gameObject, "Dice") != null)
         {
             tile.TCTool.ColourTile(Color.red);
         }
     }
 }
Beispiel #18
0
 public override void ActivateBonus()
 {
     gameObject.GetComponentInChildren <Text>().text = duration.ToString();
     gameObject.SetActive(true);
     timer    = duration;
     shooting = GameObject.FindWithTag("Player").GetComponent <ShootingScript>();
     shooting.currentBullet = shooting.bulletPrefabs.Find(bp => bp.gameObject.name == "2xPowerBullet");
     isActive = true;
     Invoke("Countdown", 1);
     Invoke("Deactivatebonus", duration);
 }
Beispiel #19
0
 // Start is called before the first frame update
 void Start()
 {
     canCraft1 = false;
     canCraft2 = false;
     canCraft3 = false;
     hoverText1.gameObject.SetActive(false);
     hoverText2.gameObject.SetActive(false);
     hoverText3.gameObject.SetActive(false);
     myshot      = GetComponentInChildren <ShootingScript>();
     myshot.shot = squirrelshot;
 }
Beispiel #20
0
    /*[Header("Variables para ir a última posición de jugador")]
     * private bool lastPositionChecked;
     * private Vector3 lastSeenPosition;
     * public float timeToWaitOnLastPosition;
     * private float timerWaitLastPos;*/

    protected virtual void Start()
    {
        m_AI_Controller                = GetComponent <NavMeshAgent>();
        m_shootingScript               = GetComponent <ShootingScript>();
        m_myRigidbody                  = GetComponent <Rigidbody2D>();
        m_originalStoppingDistance     = m_AI_Controller.stoppingDistance;
        m_AI_Controller.updateUpAxis   = false;
        m_AI_Controller.updateRotation = false;

        initialPosition = transform.position; //Posición inicial.
    }
    private void OnTriggerStay2D(Collider2D collision)
    {
        pharoahMove ph = GetComponentInParent <pharoahMove>();

        if (collision.gameObject.tag == "Dean" && Time.time > fire && ph.pharoahMovingLeft == true)
        {
            fire = Time.time + fireRateSpear;

            ShootingScript shootScript = GetComponent <ShootingScript>();
            shootScript.enemySpearLeft();
        }
    }
Beispiel #22
0
    private void Start()
    {
        shoot = GetComponent <ShootingScript>();

        shootableMask = LayerMask.GetMask("Shootable");

        targets     = new List <Transform>();
        MyTransform = transform;


        timer = 0f;
    }
Beispiel #23
0
 void StartSaveVariables()
 {
     this_EnemyControl_MovementController = GetComponent <EnemyControl_MovementController>();
     this_EnemyShootingScript             = GetComponent <ShootingScript>();
     this_EnemyActiveAbility   = GetComponent <ActiveAbility>();
     this_EnemyAI              = GetComponent <EnemyAI_Standard>();
     this_EnemyNavAgent        = GetComponent <NavMeshAgent>();
     this_EnemyHealthScript    = GetComponent <EnemyHealth>();
     player_MovementController = GameManager.Instance.realPlayerGO.GetComponent <PlayerControl_MovementController>();
     player_PossessAbility     = GameManager.Instance.realPlayerGO.GetComponent <PossessAbility>();
     thisEnemyRB = GetComponent <Rigidbody2D>();
 }
Beispiel #24
0
    /* void LaunchProjectileRoutine(ShootingScript shooter, Vector3 target)
     * {
     *
     * }*/

    public void DoShot(ShootingScript shooter, Vector3 target, GameObject _PROJECTILE)
    {
        GameObject projectile = Instantiate(_PROJECTILE) as GameObject;

        projectile.transform.position = shooter.ProjectileLauncher.position;
        projectile.transform.LookAt(target + new Vector3(0, 0.5f, 0));
        projectile.transform.Rotate(Vector3.left, 45, Space.Self);
        projectile.GetComponent <Rigidbody>().velocity = projectile.transform.forward * shooter.PROJECTILE_SPEED;
        shooter.lastShotProjectile = projectile.GetComponent <ProjectileScript>();
        projectile.GetComponent <ProjectileScript>().speed     = shooter.PROJECTILE_SPEED;
        projectile.GetComponent <ProjectileScript>().Target    = target;
        projectile.GetComponent <ProjectileScript>().myShooter = shooter;
    }
Beispiel #25
0
    // Start is called before the first frame update
    void Start()
    {
        player         = GameObject.FindGameObjectWithTag("Player");
        lyontipaikka   = GameObject.Find("MeleeWeaponEtuPlace");
        latauspaikka   = GameObject.Find("MeleeWeaponTakaPlace");
        säilytyspaikka = GameObject.Find("MeleeWeaponSäilytysPlace");

        peruspaikka    = GameObject.Find("MeleeWeaponPlace");
        keräilyScript  = player.GetComponent <Keräily>();
        shootingScript = player.GetComponent <ShootingScript>();
        takas          = false;
        esillä         = true;
    }
Beispiel #26
0
    float ChancesToHit(UnitScript currentUnit, ShootingScript shooter, UnitScript target)
    {
        float      EvaluationIncrease = 0f;
        HitChancer hc       = new HitChancer(currentUnit, target, 100);
        bool       badRange = ShootingScript.WouldItBePossibleToShoot(shooter, shooter.transform.position, target.transform.position).Value;
        // above the Value not the Key of possible to shoot at is important. It is missleading yet correct.
        float damageChance = 100 - hc.MissChance(badRange);
        // im NOT sure if line above is correct, i had to change it after changing the combat system, it might be crap.
        float temp = damageChance * 0.015f;

        EvaluationIncrease += temp;
        return(EvaluationIncrease);
    }
Beispiel #27
0
    private void OnTriggerStay2D(Collider2D collision)
    {
        robotMove rm = GetComponentInParent <robotMove>();

        if (collision.gameObject.tag == "Dean" && Time.time > fire && rm.isLeft == true)
        {
            fire = Time.time + fireRatePlasma;

            ShootingScript shootScript = GetComponent <ShootingScript>();
            shootScript.ARShootLeft();
            AudioSource.PlayClipAtPoint(ARShot, Camera.main.transform.position);
        }
    }
Beispiel #28
0
 protected override void ColourTiles()
 {
     foreach (Tile tile in Map.Board)
     {
         if (tile.myUnit != null && tile.myUnit.PlayerID != myUnit.PlayerID && ShootingScript.WouldItBePossibleToShoot(this.GetComponent <ShootingScript>(), this.transform.position, tile.transform.position).Key)
         {
             tile.TCTool.ColourTile(Color.red);
         }
         else
         {
             tile.TCTool.ColourTile(Color.white);
         }
     }
 }
Beispiel #29
0
    public override List <Tile> GetPossibleMoves(UnitScript currentUnit, bool isAlly)
    {
        List <Tile> enemiesInRange = new List <Tile>();

        foreach (UnitScript enemy in enemyList)
        {
            bool isInRange = ShootingScript.WouldItBePossibleToShoot(currentUnit.GetComponent <ShootingScript>(), currentUnit.transform.position, enemy.transform.position).Key;
            if (enemy.PlayerID != this.ID && isInRange && enemy.CurrentHP > 0)
            {
                enemiesInRange.Add(enemy.myTile);
            }
        }
        return(enemiesInRange);
    }
Beispiel #30
0
    public void ToggleHighlight()
    {
        if (GameStateManager.Instance.IsCurrentPlayerAI() || GameStateManager.Instance.GameState == GameStates.TargettingState)
        {
            return;
        }

        if (TurnManager.Instance.CurrentPhase == TurnPhases.Attack && MouseManager.Instance.SelectedUnit != null && MouseManager.Instance.SelectedUnit.CheckIfIsInCombat() == true && MouseManager.Instance.SelectedUnit.hasAttacked == false && MouseManager.Instance.SelectedUnit.CanAttack)
        {
            foreach (Tile tile in Map.Board)
            {
                if (tile.myUnit != null && tile.myUnit.PlayerID != TurnManager.Instance.PlayerHavingTurn && tile.myUnit.EnemyList.Contains(MouseManager.Instance.SelectedUnit) == true)
                {
                    tile.GetComponent <Renderer>().material.color = Color.red;
                    tile.isBeingColoredByCombatHighlighter        = true;
                }
            }
            return;
        }


        if (TurnManager.Instance.CurrentPhase == TurnPhases.Shooting && MouseManager.Instance.SelectedUnit != null && MouseManager.Instance.SelectedUnit.isRanged == true && MouseManager.Instance.SelectedUnit.GetComponent <ShootingScript>().CanShoot == true)
        {
            foreach (Tile tile in Map.Board)
            {
                if (tile.myUnit != null && tile.myUnit.PlayerID != TurnManager.Instance.PlayerHavingTurn && ShootingScript.WouldItBePossibleToShoot(MouseManager.Instance.SelectedUnit.GetComponent <ShootingScript>(), MouseManager.Instance.SelectedUnit.transform.position, tile.transform.position).Key)
                {
                    tile.GetComponent <Renderer>().material.color = Color.red;
                    tile.isBeingColoredByCombatHighlighter        = true;
                }
                else if (tile.myUnit == null && Input.GetKey(KeyCode.LeftControl) && ShootingScript.WouldItBePossibleToShoot(MouseManager.Instance.SelectedUnit.GetComponent <ShootingScript>(), MouseManager.Instance.SelectedUnit.transform.position, tile.transform.position).Key)
                {
                    tile.GetComponent <Renderer>().material.color = myColor;
                    tile.isBeingColoredByCombatHighlighter        = true;
                }
            }
            return;
        }


        foreach (Tile tile in Map.Board)
        {
            if (tile.isBeingColoredByCombatHighlighter)
            {
                tile.isBeingColoredByCombatHighlighter        = false;
                tile.GetComponent <Renderer>().material.color = Color.white;
            }
        }
    }
 void Start()
 {
     player = GetComponent<PlayerControl>();
     shooter = GetComponent<ShootingScript>();
 }