void attack()
    {
        Vector3 mouse = Vector2.zero;

        shotCounter = timeBetweenShots;


        GameObject  arrowInstance = Instantiate(arrow, rb2d.position, Quaternion.identity) as GameObject;
        Rigidbody2D arrowRB       = arrowInstance.GetComponent <Rigidbody2D>();


        mouse = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;
        arrowInstance.transform.Rotate(0, 0, (Mathf.Atan2(mouse.y, mouse.x) - 90) * Mathf.Rad2Deg);



        arrowRB.AddForce(mouse.normalized * shotForceMultiplier * tightenTime);

        ArrowBehaviour arrowScript = arrowInstance.GetComponent <ArrowBehaviour>();

        arrowScript.startPos   = transform.position;
        arrowScript.flightDist = shotDistance * tightenTime;

        tightenTime = minTighten;
        arrows--;
    }
        private ArrowBehaviour MakeArrow(int id)
        {
            // Arrow Buttons
            GameObject     arrowClone       = AssetDB.sabs["sab-comms"].Behavior.gameObject.transform.FindChild("Arrow").gameObject;
            SpriteRenderer arrowCloneSprite = arrowClone.GetComponent <SpriteRenderer>();
            GameObject     arrowObj         = new GameObject("Sabotage Arrow " + id);

            // Sprite
            SpriteRenderer arrowSprite = arrowObj.AddComponent <SpriteRenderer>();

            arrowSprite.sprite   = arrowCloneSprite.sprite;
            arrowSprite.material = arrowCloneSprite.material;
            arrowObj.layer       = (int)Layer.UI;

            // Arrow Behaviour
            ArrowBehaviour arrowBehaviour = arrowObj.AddComponent <ArrowBehaviour>();

            arrowBehaviour.image = arrowSprite;

            // Transform
            arrowObj.transform.SetParent(sabMgr.transform);
            arrowObj.transform.localScale = new Vector3(0.4f, 0.4f, 1.0f);
            arrowObj.active = false;

            return(arrowBehaviour);
        }
Exemple #3
0
    private void SetArrow(Collider2D col, bool unset)
    {
        ArrowBehaviour arrow = col.GetComponent <ArrowBehaviour> ();

        int arrowType = arrow.arrowType;

        switch (arrowType)
        {
        case 0:         //left
            this.currentLeftArrow = (!unset)?arrow:null;
            break;

        case 1:         //down
            this.currentDownArrow = (!unset)?arrow:null;
            break;

        case 2:         //up
            this.currentUpArrow = (!unset)?arrow:null;
            break;

        case 3:         //right
            this.currentRightArrow = (!unset)?arrow:null;
            break;
        }
    }
Exemple #4
0
 public void OnCollisionEnter2D(Collision2D collider)
 {
     if (gameObject.activeSelf)
     {
         if (hasLanded)
         {
             return;
         }
         hasLanded = true;
         DieBehaviour   die = collider.gameObject.GetComponent <DieBehaviour>();
         ArrowBehaviour arr = collider.gameObject.GetComponent <ArrowBehaviour>();
         if (die != null)
         {
             Instantiate(blood, collider.contacts[0].point, Quaternion.identity);
             die.Kill(" got hit by an arrow");
             gameObject.SetActive(false);
         }
         if (arr != null)
         {
             gameObject.SetActive(false);                //Destroy(gameObject);
         }
         this.collider.enabled = false;
         GetComponent <Rigidbody2D>().isKinematic = true;
         //transform.parent = collider.transform;
     }
 }
        public SabBuilder(PolusHandler polus)
        {
            this.polus = polus;
            sabMgr     = new GameObject("SabManager");

            sabArrow1 = MakeArrow(1);
            sabArrow2 = MakeArrow(2);
        }
Exemple #6
0
 void ActivateArrow_RPC()
 {
     if (FindObjectOfType <ArrowBehaviour>() != null)
     {
         arrowBehaviour = FindObjectOfType <ArrowBehaviour>();
         arrowBehaviour.ReadyUp();
     }
 }
 void Start()
 {
     showArrow = false;
     objectives = new List<GameObject> ();
     prevObjectives = new List<GameObject>();
     arrow = transform.GetChild (0).gameObject;
     ab = arrow.GetComponent<ArrowBehaviour> ();
 }
Exemple #8
0
 public Arrow(Color color)
 {
     arrow                = new GameObject("Arrow");
     arrow.layer          = 5;
     image                = arrow.AddComponent <SpriteRenderer>();
     image.sprite         = getSprite();
     image.color          = color;
     arrowBehaviour       = arrow.AddComponent <ArrowBehaviour>();
     arrowBehaviour.image = image;
 }
Exemple #9
0
    private void Shoot()
    {
        GameObject o = Instantiate(Arrow);

        o.transform.position = transform.position;
        ArrowBehaviour arr = o.GetComponent <ArrowBehaviour>();
        Vector2        dir = MyUtility.GetAxisOriented(PlayerController.get().transform.position - transform.position);

        arr.Shoot(controller, dir.normalized, ArrowSpeed);
    }
Exemple #10
0
    public void Clicked()
    {
        foreach (Herrow h in GameRules.Instance.herrows)
        {
            if (h.card == curr)
            {
                thisHerrow = h;
                foreach (GameplayBehaviour beh in GameRules.Instance.allBehaviours)
                {
                    if (beh.ToString().Contains("Arrow") && beh.isActiveAndEnabled)
                    {
                        beh.GetComponentInChildren <SkeletonAnimator>().skeletonDataAsset = h.skin;
                        beh.GetComponentInChildren <SkeletonRenderer>().Initialize(true);
                        beh.GetComponentInChildren <Animator>().runtimeAnimatorController = h.controller;
                        beh.GetComponent <Ability>().thisAbility = h.ability;
                        GetComponentInParent <AudioSource>().Play();
                        AudioSource    soundEmitter = beh.GetComponent <AudioSource>();
                        ArrowBehaviour a            = beh.GetComponent <ArrowBehaviour>();
                        switch (h.ability)
                        {
                        case Ability.HerrowAbility.None:
                        {
                            soundEmitter.clip = a.sounds[0];
                            break;
                        }

                        case Ability.HerrowAbility.Freeze:
                        {
                            soundEmitter.clip = a.sounds[4];
                            break;
                        }

                        case Ability.HerrowAbility.Incorporeal:
                        {
                            soundEmitter.clip = a.sounds[2];
                            break;
                        }
                        }
                        soundEmitter.Play();
                        //if (h.rarity!=Herrow.Rarity.Common) {
                        //    used[GameRules.Instance.currentPlayer]=true;

                        //}
                        popupQuiver pq = gameObject.GetComponentInParent <popupQuiver>();
                        if (pq != null)
                        {
                            pq.gameObject.SetActive(false);
                        }

                        break;
                    }
                }
            }
        }
    }
Exemple #11
0
 public static void RemoveArrows()
 {
     ArrowCreated = false;
     if (Arrow == null)
     {
         return;
     }
     Arrow.gameObject.Destroy();
     Arrow = null;
     PluginSingleton <TownOfUs> .Instance.Log.LogMessage("DELETED ARROW");
 }
        public VisualArrow(Vector3 target, int id)
        {
            gameObj = new GameObject {
                layer = 5
            };
            arrow        = gameObj.AddComponent <ArrowBehaviour>();
            arrow.target = target;
            SpriteRenderer renderer = gameObj.AddComponent <SpriteRenderer>();

            arrow.image     = renderer;
            renderer.sprite = Utilities.LoadSpriteFromAssemblyResource(Assembly.GetExecutingAssembly(), ARROW_RES_PATH);
            arrows.Add(new Tuple <int, VisualArrow>(id, this));
        }
Exemple #13
0
    private void ThrowArrow()
    {
        ArrowBehaviour arrowToThrow  = null;
        int            arrowsToThrow = Random.Range(1, this.arrowsToThrow + 1);

        for (int i = 0; i < arrowsToThrow; i++)
        {
            arrowToThrow = this.GetArrow();
            arrowToThrow.Move(4, -3);
            this.arrowsThrowed++;
        }

        this.ResetAvailableArrows();
    }
Exemple #14
0
    // Start is called before the first frame update
    void Start()
    {
        //PlayerPrefs.SetInt("Planet", 0);
        if (AvoidanceController.instance.arcade)
        {
            PlayerPrefs.SetInt("Planet", 0);
        }
        planet = PlayerPrefs.GetInt("Planet", 0);
        rb     = GetComponent <Rigidbody2D>();
        ab     = arrow.GetComponent <ArrowBehaviour>();

        if (planet > 0)
        {
            ab.i = planet + 1;
            transform.position = new Vector3(-4, 0) + ab.planet[planet].transform.position;
        }
    }
Exemple #15
0
        public static void GenArrows()
        {
            ArrowCreated = true;
            PerformKill.UsedThisRound = true;
            PerformKill.SabotageTime  = DateTime.Now;
            if (PlayerControl.LocalPlayer.Data.IsDead || !PlayerControl.LocalPlayer.Data.IsImpostor ||
                Utils.Engineer.Data.IsDead)
            {
                return;
            }
            var gameobj = new GameObject();

            Arrow = gameobj.AddComponent <ArrowBehaviour>();
            gameobj.transform.parent = PlayerControl.LocalPlayer.gameObject.transform;
            var renderer = gameobj.AddComponent <SpriteRenderer>();

            renderer.sprite = Sprite;
            Arrow.image     = renderer;
            gameobj.layer   = 5;
            PluginSingleton <TownOfUs> .Instance.Log.LogMessage("CREATED ARROW");
        }
Exemple #16
0
    private ArrowBehaviour GetArrow()
    {
        int arrowTypeToThrow = this.availableArrowTypes [0];

        this.availableArrowTypes.Remove(arrowTypeToThrow);

        Transform      arrowToThrow   = this.arrowPool.Get().transform;
        SpriteRenderer arrowSprite    = arrowToThrow.GetComponent <SpriteRenderer> ();
        ArrowBehaviour arrowBehaviour = arrowToThrow.GetComponent <ArrowBehaviour> ();

        arrowBehaviour.arrowType    = arrowTypeToThrow;
        arrowBehaviour.OnHit       += this.ArrowHit;
        arrowBehaviour.OnErrorSave += this.guitarHero.HitError;

        arrowSprite.color = this.arrowColors [arrowTypeToThrow];

        arrowToThrow.localPosition = new Vector2(this.arrowXPositions [arrowTypeToThrow], 5);

        arrowToThrow.gameObject.SetActive(true);
        return(arrowBehaviour);
    }
Exemple #17
0
    public void shoot(GameObject projectile, Vector3 position, GameObject arch, float angle, float force, Material color)
    {
        GameObject arrow = Instantiate(projectile, position + arch.transform.forward, arch.transform.rotation);



        arrow.SetActive(true);
        arrow.name = "Arrow";

        ArrowBehaviour be = arrow.GetComponent <ArrowBehaviour>();

        be.shooter = arch;
        Rigidbody rb = arrow.GetComponent <Rigidbody>();

        Renderer rnd = arrow.GetComponentInChildren <Renderer>();

        Material[] col = rnd.materials;
        col[0]        = color;
        rnd.materials = col;

        rb.velocity = ((arch.transform.forward * force * Mathf.Cos(angle) * 0.110f) + (arch.transform.up * force * Mathf.Sin(angle)) * 0.07f);
    }
Exemple #18
0
        public static IEnumerator AltruistRevive(DeadBody target, Altruist role)
        {
            var parentId = target.ParentId;
            var position = target.TruePosition;

            var revived = new List <PlayerControl>();


            Utils.MurderPlayer(role.Player, role.Player);

            if (CustomGameOptions.AltruistTargetBody)
            {
                if (target != null)
                {
                    Object.Destroy(target.gameObject);
                }
            }

            var startTime = DateTime.UtcNow;

            while (true)
            {
                var now     = DateTime.UtcNow;
                var seconds = (now - startTime).TotalSeconds;
                if (seconds < CustomGameOptions.ReviveDuration)
                {
                    yield return(null);
                }
                else
                {
                    break;
                }

                if (MeetingHud.Instance)
                {
                    yield break;
                }
            }

            var altruistBody = Object.FindObjectsOfType <DeadBody>().FirstOrDefault(b => b.ParentId == role.Player.PlayerId);

            if (altruistBody != null)
            {
                Object.Destroy(altruistBody.gameObject);
            }

            var player = Utils.PlayerById(parentId);


            player.Revive();
            MedicMod.Murder.KilledPlayers.Remove(
                MedicMod.Murder.KilledPlayers.FirstOrDefault(x => x.PlayerId == player.PlayerId));
            revived.Add(player);
            player.NetTransform.SnapTo(position);

            if (target != null)
            {
                Object.Destroy(target.gameObject);
            }

            if (player.isLover())
            {
                var lover = Roles.Role.GetRole <Lover>(player).OtherLover.Player;

                lover.Revive();
                MedicMod.Murder.KilledPlayers.Remove(
                    MedicMod.Murder.KilledPlayers.FirstOrDefault(x => x.PlayerId == lover.PlayerId));
                revived.Add(lover);

                var loverBody = Object.FindObjectsOfType <DeadBody>().FirstOrDefault(b => b.ParentId == lover.PlayerId);

                if (loverBody != null)
                {
                    lover.NetTransform.SnapTo(loverBody.TruePosition);
                    Object.Destroy(loverBody.gameObject);
                }
            }

            if (revived.Any(x => x.AmOwner))
            {
                try
                {
                    Minigame.Instance.Close();
                    Minigame.Instance.Close();
                }
                catch
                {
                }
            }


            if (PlayerControl.LocalPlayer.Data.IsImpostor)
            {
                var gameObj = new GameObject();
                Arrow = gameObj.AddComponent <ArrowBehaviour>();
                gameObj.transform.parent = PlayerControl.LocalPlayer.gameObject.transform;
                var renderer = gameObj.AddComponent <SpriteRenderer>();
                renderer.sprite = Sprite;
                Arrow.image     = renderer;
                gameObj.layer   = 5;
                Target          = player;
                yield return(Utils.FlashCoroutine(role.Color, 1f, 0.5f));
            }
        }
Exemple #19
0
        public static IEnumerator AltruistRevive(DeadBody target, Altruist role)
        {
            var parentId = target.ParentId;
            var position = target.TruePosition;

            var revived = new List <PlayerControl>();


            if (AmongUsClient.Instance.AmHost)
            {
                Utils.RpcMurderPlayer(role.Player, role.Player);
            }

            if (CustomGameOptions.AltruistTargetBody)
            {
                if (target != null)
                {
                    foreach (DeadBody deadBody in GameObject.FindObjectsOfType <DeadBody>())
                    {
                        if (deadBody.ParentId == target.ParentId)
                        {
                            deadBody.gameObject.Destroy();
                        }
                    }
                }
            }

            var startTime = DateTime.UtcNow;

            while (true)
            {
                var now     = DateTime.UtcNow;
                var seconds = (now - startTime).TotalSeconds;
                if (seconds < CustomGameOptions.ReviveDuration)
                {
                    yield return(null);
                }
                else
                {
                    break;
                }

                if (MeetingHud.Instance)
                {
                    yield break;
                }
            }

            foreach (DeadBody deadBody in GameObject.FindObjectsOfType <DeadBody>())
            {
                if (deadBody.ParentId == role.Player.PlayerId)
                {
                    deadBody.gameObject.Destroy();
                }
            }

            var player = Utils.PlayerById(parentId);

            // if (player == null || AmongUsClient.Instance.GameState != InnerNetClient.GameStates.Started)
            //     yield break;

            player.Revive();
            Murder.KilledPlayers.Remove(
                Murder.KilledPlayers.FirstOrDefault(x => x.PlayerId == player.PlayerId));
            revived.Add(player);
            player.NetTransform.SnapTo(position);

            if (target != null)
            {
                Object.Destroy(target.gameObject);
            }

            if (player.isLover() && CustomGameOptions.BothLoversDie)
            {
                var lover = Role.GetRole <Lover>(player).OtherLover.Player;

                lover.Revive();
                Murder.KilledPlayers.Remove(
                    Murder.KilledPlayers.FirstOrDefault(x => x.PlayerId == lover.PlayerId));
                revived.Add(lover);

                foreach (DeadBody deadBody in GameObject.FindObjectsOfType <DeadBody>())
                {
                    if (deadBody.ParentId == lover.PlayerId)
                    {
                        deadBody.gameObject.Destroy();
                    }
                }
            }

            if (revived.Any(x => x.AmOwner))
            {
                try
                {
                    Minigame.Instance.Close();
                    Minigame.Instance.Close();
                }
                catch
                {
                }
            }


            if (PlayerControl.LocalPlayer.Data.IsImpostor || PlayerControl.LocalPlayer.Is(RoleEnum.Glitch))
            {
                var gameObj = new GameObject();
                Arrow = gameObj.AddComponent <ArrowBehaviour>();
                gameObj.transform.parent = PlayerControl.LocalPlayer.gameObject.transform;
                var renderer = gameObj.AddComponent <SpriteRenderer>();
                renderer.sprite = Sprite;
                Arrow.image     = renderer;
                gameObj.layer   = 5;
                Target          = player;
                yield return(Utils.FlashCoroutine(role.Color, 1f, 0.5f));
            }
        }
Exemple #20
0
 private void ArrowHit(ArrowBehaviour arrow, bool center)
 {
     arrow.OnErrorSave -= this.guitarHero.HitError;
     this.guitarHero.SumPoints(center);
 }