Esempio n. 1
0
    public void Initialize(GhostAIStats stats)
    {
        this.stats = stats;
        stats.self = this;
        NotificationMaster.playerObservers.Add(this);

        float aggro = stats.Aggressiveness();

        if (aggro > 0)
        {
            attack = gameObject.AddComponent <GhostAttack>();
            GetComponent <GhostAttack> ().Initialize(stats);
        }

        movement = gameObject.GetComponent <GhostMovement>();
        movement.Initialize(stats);

        detectionRadius = Room.bounds.extents.x;

        transform.localScale = new Vector3(stats.size, stats.size, 1);

        size = GetComponent <SpriteRenderer>().bounds.extents;

        transform.position     = movement.GetSpawnPosition(size);
        movement.startPosition = transform.position;

        layerMask = 1 << LayerMask.NameToLayer("Wall") | 1 << LayerMask.NameToLayer("Player");

        GetComponent <SpriteRenderer>().sortingOrder = (int)(1.0f / size.magnitude * 1000);

        AdjustColors(aggro);

        animate = GetComponent <Animate>();
        animate.AnimateToColor(Palette.Invisible, color, .3f);
    }
Esempio n. 2
0
    public virtual void attack()
    {
        if (type == MonsterManager.MonsterType.BOMB && 1 <= attackRegister && attackRegister <= 10)
        {
            GameObject bullet = null;
            bullet = Instantiate(atkPrefab, this.transform.position, Quaternion.identity);

            GhostAttack attackInfo = bullet.GetComponent <GhostAttack>();
            attackInfo.ad          = atk;
            attackInfo.attackRange = 1;

            GameObject.Find("center").GetComponent <MonsterManager>().DeadMonster(gameObject);
        }

        if (attackRegister > 0)
        {
            return;
        }

        if (type == MonsterManager.MonsterType.BOMB)
        {
            Animator animator = GetComponent <Animator>();
            animator.SetTrigger("explsion");
        }
        else
        {
            GameObject bullet = null;
            bullet = Instantiate(atkPrefab, this.transform.position, Quaternion.identity);

            if (type == MonsterManager.MonsterType.SKUL)
            {
                GhostAttack attackInfo = bullet.GetComponent <GhostAttack>();
                attackInfo.ad          = atk;
                attackInfo.attackRange = atkRange;
                attackInfo.speed       = 1;
            }
            else if (type == MonsterManager.MonsterType.GHOST)
            {
                GhostAttack attackInfo = bullet.GetComponent <GhostAttack>();
                attackInfo.ad          = atk * 2;
                attackInfo.attackRange = atkRange;
                attackInfo.speed       = 2;
            }
            else if (type == MonsterManager.MonsterType.WITCH)
            {
                GhostAttack attackInfo = bullet.GetComponent <GhostAttack>();
                attackInfo.ad          = atk * 2;
                attackInfo.attackRange = atkRange;
                attackInfo.speed       = 3;
            }
        }


        attackRegister = 60;
    }