Пример #1
0
    public override void OnSignalRecieved(eObject source, string[] signal)
    {
        base.OnSignalRecieved(source, signal);

        Debug.Log(signal[0]);

        switch (signal[0])
        {
        case "damage":
        case "damageToEnemy":
            if (!turnedOn)
            {
                turnedOn = true;
                GetComponent <Renderer>().material = debugtmp_newMaterial;
                m_camCtrl.cameraMoveTo(cameraPos.position, cameraPos.rotation);
                TriggerEvent(this, "Activate", 1.0f);
                TriggerEvent(this, "cameraRet", 3.0f);
                TriggerEvent(this, "isOver", 4.0f);
            }
            break;

        case "Activate":
            TriggerEvent(targetObject, message);
            break;

        case "cameraRet":
            m_camCtrl.cameraMoveBack();
            break;

            //todo: camera movement
        }
    }
    public override void OnSignalRecieved(eObject source, string[] signal)
    {
        base.OnSignalRecieved(source, signal);

        switch (signal[0])
        {
        case "cast":
            m_isCasting = true;

            StopChargeEffect();

            m_targetRotation = Quaternion.FromToRotation(
                Vector3.up,
                m_targetPos - transform.position);
            m_targetDistance = (m_targetPos - transform.position).magnitude;
            m_rotateSpeed    = Quaternion.Angle(transform.rotation, m_targetRotation);

            Debug.Log(m_targetDistance);
            break;

        case "static":
            m_isStatic = true;
            m_coreObject.GetComponent <BossGT_BaseAttackCoreObject>().isStatic = true;
            m_effectArea = Instantiate(m_effectArea, new Vector3(m_coreObject.transform.position.x, 0.0f, m_coreObject.transform.position.z), Quaternion.identity);
            break;
        }
    }
Пример #3
0
        private void insertPictureOrSoundFile(string card_value, int cid, int side, string type,
                                              int x1, int x2, int y1, int y2)
        {
            try
            {
                char[] param = new char[1];
                param[0] = '\\';
                string[]   card_value_array = card_value.Split(param);
                string     filename         = card_value_array[card_value_array.Length - 1];
                byte[]     _rawData;
                FileStream file;
                file     = new FileStream(card_value, FileMode.Open, FileAccess.Read);
                _rawData = new byte[(int)file.Length];
                file.Read(_rawData, 0, (int)file.Length);
                file.Close();
                eObject curObj = new eObject(cid, side, type, x1, x2, y1, y2);
                curObj.efile = new eFile(_rawData);


                curObj.save();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #4
0
    public override void OnSignalRecieved(eObject source, string[] signal)
    {
        base.OnSignalRecieved(source, signal);

        switch (signal[0])
        {
        case "Activate":
            if (!opening && !opened)
            {
                opening = true;
                TriggerEvent(this, "opened", 3.0f);
            }
            break;

        case "opened":
            opening = false;
            opened  = true;
            break;

        case "Disable":
            if (!closing && opened)
            {
                closing = true;
                TriggerEvent(this, "closed", 3.0f);
            }
            break;

        case "closed":
            closing = false;
            opened  = false;
            break;
        }
    }
Пример #5
0
    public override void OnSignalRecieved(eObject source, string[] signal)
    {
        base.OnSignalRecieved(source, signal);

        switch (signal[0])
        {
        case "Activate":
            foreach (eObject e in objectList)
            {
                if (moveCam)
                {
                    TriggerEvent(e, message, 1.0f);
                }
                else
                {
                    TriggerEvent(e, message);
                }
            }

            if (moveCam)
            {
                m_camCtrl.cameraMoveTo(camHelper.position, camHelper.rotation);
                TriggerEvent(this, "cameraRet", 3.0f);
            }
            break;

        case "cameraRet":
            m_camCtrl.cameraMoveBack();
            break;
        }
    }
Пример #6
0
        public static void initText(eObject obj, Panel panel)
        {
            int Left   = obj.x1 * Constant.cardWidth / 100;
            int Top    = obj.y1 * Constant.cardHeight / 100;
            int Width  = (obj.x2 - obj.x1) * Constant.cardWidth / 100;
            int Height = (obj.y2 - obj.y1) * Constant.cardHeight / 100;

            string      textToDisplay = obj.data;
            RichTextBox txtText       = new RichTextBox();

            try
            {
                txtText.LoadFile(Constant.ePath + textToDisplay, RichTextBoxStreamType.RichText);
            }
            catch (Exception e)
            {
                MessageBox.Show("file not found");
            }
            txtText.Location    = new System.Drawing.Point(Left, Top);
            txtText.ReadOnly    = true;
            txtText.ScrollBars  = System.Windows.Forms.RichTextBoxScrollBars.None;
            txtText.Size        = new System.Drawing.Size(Width, Height);
            txtText.TabStop     = false;
            txtText.BorderStyle = System.Windows.Forms.BorderStyle.None;
            txtText.BackColor   = System.Drawing.Color.White;
            txtText.DetectUrls  = false;

            panel.Controls.Add(txtText);
        }
Пример #7
0
    public override void OnSignalRecieved(eObject source, string[] signal)
    {
        base.OnSignalRecieved(source, signal);

        switch (signal[0])
        {
        case "Activate":
            if (gameObject.GetComponent <Renderer>())
            {
                gameObject.GetComponent <Renderer>().enabled = true;
            }
            begin = true;
            TriggerEvent(this, "stop", 1.0f);
            //camCtrl.cameraMoveTo(transform.Find("CameraHelper").position, transform.Find("CameraHelper").rotation);
            //TriggerEvent(this, "CameraRet", 3.0f);
            break;

        case "stop":
            begin = false;
            break;

            //case "CameraRet":
            //    camCtrl.cameraMoveBack();
            //    break;
        }
    }
Пример #8
0
    public override void OnSignalRecieved(eObject source, string[] signal)
    {
        base.OnSignalRecieved(source, signal);

        switch (signal[0])
        {
        case "playerPos":
            hasPos      = true;
            playerPos.x = float.Parse(signal[1]);
            playerPos.y = float.Parse(signal[2]);
            playerPos.z = float.Parse(signal[3]);
            break;

        //case "damage":
        //    health -= float.Parse(signal[1]);
        //    Debug.Log(health);
        //    Vector3 diff;
        //    diff.x = float.Parse(signal[2]);
        //    diff.y = float.Parse(signal[3]);
        //    diff.z = float.Parse(signal[4]);

        //    diff = transform.position - diff;
        //    diff.y = 0;
        //    hitbackSpeed = diff.normalized * 5f; //5: hitback speed
        //    break;

        case "attack":
            TriggerEvent(this, "attack", attackGap, false);

            if (hasPos && Vector3.Distance(transform.position, playerPos) <= attackRange)
            {
                TriggerEvent(this, "attackGo", channelingTime, false);
                slowed = true;
            }
            break;

        case "attackGo":
            Instantiate(attackObject, transform.position + transform.rotation * new Vector3(0.0f, 0.3f, 0.75f), transform.rotation).
            GetComponent <Enemy_StrightBulletObj>().target = GameObject.FindGameObjectWithTag("Player").transform;
            slowed = false;
            break;

        case "playerEnter":
            //TriggerEvent (this, "attack");
            hasPos = true;
            break;

        case "playerExit":
            hasPos = false;
            break;

        case "attackThunder":
            TriggerEvent(this, "attackThunder", thunderGap, false);

            Vector2 rnd     = Random.insideUnitCircle;
            eObject thunder = Instantiate(m_thunderPrefab, transform.position + new Vector3(rnd.x, 0, rnd.y) * 8.0f, Quaternion.identity).GetComponent <eObject>();
            thunder.TriggerEvent(thunder, "Activate", 2.5f);
            break;
        }
    }
Пример #9
0
    public override void OnSignalRecieved(eObject source, string[] signal)
    {
        base.OnSignalRecieved(source, signal);

        switch (signal[0])
        {
        case "Activate":
            GameObject rangedBomb = Instantiate(rangeAttacker, transform.position, transform.rotation);
            rangedBomb.GetComponent <SpringBomAttack>().SetAttack(bombDamage, range);

            Destroy(gameObject);
            break;

        case "enterWind":
            m_rigidBody.AddForce(150f * Vector3.up);
            break;

        case "inWind":
            inWind   = true;
            windDirc = ((Wind)source).windDirc;
            break;

        case "inCyclone":
            inCyclone    = true;
            cyclonePivot = ((Cyclone)source).cyclonePivot;
            break;
        }
    }
Пример #10
0
        public static void initImage(eObject obj, Panel panel )
        {
            int Left = obj.x1 * Constant.cardWidth / 100;
            int Top = obj.y1 * Constant.cardHeight / 100;
            int Width = (obj.x2 - obj.x1) * Constant.cardWidth / 100;
            int Height = (obj.y2 - obj.y1) * Constant.cardHeight / 100;

            string fileToDisplay = obj.data;
            PictureBox pictureBox = new PictureBox();

            //set up picturebox
            pictureBox.Location = new System.Drawing.Point(Left, Top);
            pictureBox.Size = new System.Drawing.Size(Width, Height);
            pictureBox.TabStop = false;
            pictureBox.SizeMode = PictureBoxSizeMode.StretchImage;
            pictureBox.BorderStyle = BorderStyle.None;
            pictureBox.Visible = true;
            panel.Controls.Add(pictureBox);
            //pictureBox.Show();

            try
            {
                // Stretches the image to fit the pictureBox.
                pictureBox.SizeMode = PictureBoxSizeMode.StretchImage;
                Bitmap MyImage = new Bitmap(Constant.ePath+fileToDisplay);
                pictureBox.ClientSize = new Size(Width, Height);
                pictureBox.Image = (Image)MyImage;
            }
            catch (Exception exc)
            {
                //MessageBox.Show("Cannot Open");

            }
        }
Пример #11
0
    public override void OnSignalRecieved(eObject source, string[] signal)
    {
        base.OnSignalRecieved(source, signal);

        switch (signal[0])
        {
        case "Activate":
            m_activated = true;
            TriggerEvent(this, "cyclone");
            break;

        case "Disable":
            StopAllCoroutines();
            m_activated = false;
            break;

        case "cyclone":
            Cyclone cyc = Instantiate(cycloneObj, transform.position, Quaternion.identity).GetComponent <Cyclone>();
            cyc.velocity = transform.rotation * Vector3.forward * cycloneSpeed;
            TriggerEvent(cyc, "cyclone " + cycloneLenth / cycloneSpeed, 0.1f);
            Destroy(cyc.gameObject, cycloneLenth / cycloneSpeed + 0.5f);

            if (m_activated == true)
            {
                TriggerEvent(this, "cyclone", cycloneGap);
            }
            break;
        }
    }
Пример #12
0
    public override void OnSignalRecieved(eObject source, string[] signal)
    {
        base.OnSignalRecieved(source, signal);

        switch (signal[0])
        {
        case "Activate":
            m_thunderCore.Play();
            TriggerEvent(this, "attackFx", 0.2f);
            TriggerEvent(this, "attackFinish", 0.5f);
            TriggerEvent(this, "attackFinishFx", 2.0f);
            break;

        case "attackFx":
            m_thunderFx.Play();
            m_attackArea.Stop();
            m_attackCharge.Stop();
            GetComponent <SphereCollider>().enabled = true;
            break;

        case "attackFinish":
            GetComponent <SphereCollider>().enabled = false;
            break;

        case "attackFinishFx":
            Destroy(this.gameObject);
            break;
        }
    }
Пример #13
0
    public override void OnObjectEnter(eObject obj)
    {
        base.OnObjectEnter(obj);

        TriggerEvent(obj, "damageToEnemy " + objDamage +
                     " " + Toolbox.ToRawString(transform.position));
    }
Пример #14
0
 // Use this for initialization
 void Start()
 {
     m_playerSlime = GameObject.FindWithTag("Player").GetComponent <Slime>();
     camCtrl       = GameObject.Find("CameraController").GetComponent <CameraController>();
     dShower       = GameObject.Find("DialogShower").GetComponent <DialogShower>();
     cameraPos     = transform.Find("CameraHelper").transform;
 }
Пример #15
0
        public static void initImage(eObject obj, Panel panel)
        {
            int Left   = obj.x1 * Constant.cardWidth / 100;
            int Top    = obj.y1 * Constant.cardHeight / 100;
            int Width  = (obj.x2 - obj.x1) * Constant.cardWidth / 100;
            int Height = (obj.y2 - obj.y1) * Constant.cardHeight / 100;

            string     fileToDisplay = obj.data;
            PictureBox pictureBox    = new PictureBox();

            //set up picturebox
            pictureBox.Location    = new System.Drawing.Point(Left, Top);
            pictureBox.Size        = new System.Drawing.Size(Width, Height);
            pictureBox.TabStop     = false;
            pictureBox.SizeMode    = PictureBoxSizeMode.StretchImage;
            pictureBox.BorderStyle = BorderStyle.None;
            pictureBox.Visible     = true;
            panel.Controls.Add(pictureBox);
            //pictureBox.Show();



            try
            {
                // Stretches the image to fit the pictureBox.
                pictureBox.SizeMode = PictureBoxSizeMode.StretchImage;
                Bitmap MyImage = new Bitmap(Constant.ePath + fileToDisplay);
                pictureBox.ClientSize = new Size(Width, Height);
                pictureBox.Image      = (Image)MyImage;
            }
            catch (Exception exc)
            {
                //MessageBox.Show("Cannot Open");
            }
        }
Пример #16
0
    protected override void OnDeath(float damage, Vector3 dirc, eObject sourceDoDamage)
    {
        base.OnDeath(damage, dirc, sourceDoDamage);

        float manaPercentage = GameDataKeeper.GetSingleton().currentMagic / GameDataKeeper.GetSingleton().maxMagic;
        float goldAmount     = (0.5f + 0.5f * manaPercentage) * goldAmountMax * Random.Range(0.7f, 1.0f);
        float manaAmount     = (1.0f - manaPercentage) * manaAmountMax * Random.Range(0.6f, 1.0f);
        float healthAmount   = (1.0f - (GameDataKeeper.GetSingleton().currentHealth / GameDataKeeper.GetSingleton().maxHealth)) * healthAmountMax * Random.Range(0.5f, 1.0f);

        for (int i = 0; i < goldAmount; i++)
        {
            Vector2    dircHor = Random.insideUnitCircle;
            Vector3    dircObj = new Vector3(dircHor.x, Random.Range(0.8f, 1.2f), dircHor.y).normalized;
            GameObject obj     = Instantiate(goldItem, transform.position + dircObj * 0.5f, Quaternion.identity);
            obj.GetComponent <Rigidbody>().AddForce(dircObj * 200.0f);
        }

        for (int i = 0; i < manaAmount; i++)
        {
            Vector2    dircHor = Random.insideUnitCircle;
            Vector3    dircObj = new Vector3(dircHor.x, Random.Range(0.8f, 1.2f), dircHor.y).normalized;
            GameObject obj     = Instantiate(manaItem, transform.position + dircObj * 0.5f, Quaternion.identity);
            obj.GetComponent <Rigidbody>().AddForce(dircObj * 200.0f);
        }

        for (int i = 0; i < healthAmount; i++)
        {
            Vector2    dircHor = Random.insideUnitCircle;
            Vector3    dircObj = new Vector3(dircHor.x, Random.Range(0.8f, 1.2f), dircHor.y).normalized;
            GameObject obj     = Instantiate(healthItem, transform.position + dircObj * 0.5f, Quaternion.identity);
            obj.GetComponent <Rigidbody>().AddForce(dircObj * 200.0f);
        }
    }
Пример #17
0
    public override void OnSignalRecieved(eObject source, string[] signal)
    {
        base.OnSignalRecieved(source, signal);

        switch (signal[0])
        {
        case "attack":
            if (Vector3.Distance(target.position, transform.position) < attackRange)
            {
                TriggerEvent(this, "attackOn " + singleAttackCount, 0.0f, false);
            }
            TriggerEvent(this, "attack", attackGap, false);
            break;

        case "attackOn":

            int index = int.Parse(signal[1]);
            if (index <= 0)
            {
                break;
            }

            Instantiate(attackObject, transform.position + transform.rotation * new Vector3(0.0f, 0.3f, 0.75f), transform.rotation).
            GetComponent <Enemy_StrightBulletObj>().target = target;
            TriggerEvent(this, "attackOn " + (index - 1), attackGapSmall, false);
            break;
        }
    }
Пример #18
0
    public bool TriggerEvent(eObject target, string signal, float delay = 0, bool showInDebug = true)
    {
        if (target == null)
        {
            return(false);
        }

        if (delay == 0)
        {
            if (showInDebug)
            {
                Debug.Log("Event: " + this.name + "(" + this.GetType().ToString() + ")\tTO\t" + target.name + "(" + target.GetType().ToString() + ") :\t\t" + signal);
            }

            target.OnSignalRecieved(this, signal.Split(' '));
            return(true);
        }

        StartCoroutine(DelayToInvoke.DelayToInvokeDo(() =>
        {
            if (target != null)
            {
                if (showInDebug)
                {
                    Debug.Log("Event: " + this.name + "(" + this.GetType().ToString() + ")\tTO\t" + target.name + "(" + target.GetType().ToString() + ") :\t\t" + signal);
                }

                target.OnSignalRecieved(this, signal.Split(' '));
            }
        }, delay));

        return(true);
    }
Пример #19
0
    public override void OnSignalRecieved(eObject source, string[] signal)
    {
        base.OnSignalRecieved(source, signal);

        switch (signal[0])
        {
        case "dialog":
            if (passageDict.ContainsKey(signal[1]))
            {
                isDialogShowing = true;
                dialogParent    = source;
                chatBoxRoot.SetActive(true);
                //chatClicker.SetActive(true);
                m_dialogIndexNext = passageDict[signal[1]];
                m_pStart          = m_dialogIndexNext;
                ShowDialog();
            }
            break;

        case "dialogContinue":
            ShowDialog();
            break;

        case "wait4click":
            if (m_state == DialogShowerState.Showing)
            {
                m_state = DialogShowerState.WaitForClick;
            }
            break;

        case "dialogEnd":
            isDialogShowing = false;
            m_state         = DialogShowerState.Unused;
            chatBoxRoot.SetActive(false);
            //chatClicker.SetActive(false);
            selectionRoot.SetActive(false);

            TriggerEvent(dialogParent, "dialogEnd");

            dialogParent = null;
            break;

        default:
            Debug.Log(signal[0]);
            string str = "";
            for (int i = 0; i < signal.Length; i++)
            {
                if (i < signal.Length - 1)
                {
                    str = str + signal[i] + " ";
                }
                else
                {
                    str = str + signal[i];
                }
            }
            TriggerEvent(dialogParent, str);
            break;
        }
    }
Пример #20
0
    public override void OnSignalRecieved(eObject source, string[] signal)
    {
        base.OnSignalRecieved(source, signal);

        switch (signal[0])
        {
        case "next":
            if (roadId == -1)
            {
                roadId = Random.Range(0, emitters.Length);
            }
            else
            {
                int roadOffset = Random.Range(1, maxDistance + 1) * (Random.Range(-10.0f, 10.0f) > 0 ? (+1) : (-1));
                roadId = roadId + roadOffset;
                roadId = Mathf.Clamp(roadId, 0, emitters.Length - 1);
            }

            Debug.Log(roadId);

            for (int i = 0; i < emitters.Length; i++)
            {
                if (i != roadId)
                {
                    TriggerEvent(emitters[i], "cyclone");
                }
            }

            TriggerEvent(this, "next", cycloneGap);
            break;
        }
    }
Пример #21
0
    public override void OnObjectEnter(eObject obj)
    {
        base.OnObjectEnter(obj);

        Destroy(Instantiate(explodeFx, transform.position, Quaternion.identity), 0.5f);
        TriggerEvent(obj, "damage " + damage + " " + Toolbox.ToRawString(transform.position));
        Destroy(gameObject, 0.02f);
    }
Пример #22
0
 public virtual void BeHealed(float healing, string[] originalSignal, eObject sourceDoHeal = null)
 {
     health += healing;
     if (health > maxHealth)
     {
         health = maxHealth;
     }
 }
Пример #23
0
    protected override void OnDeath(float damage, Vector3 dirc, eObject sourceDoDamage)
    {
        base.OnDeath(damage, dirc, sourceDoDamage);

        Instantiate(boomEffect, transform.position, Quaternion.identity);

        Destroy(gameObject);
    }
Пример #24
0
    public override void OnObjectEnter(eObject obj)
    {
        base.OnObjectEnter(obj);

        if (obj.GetState("player") > 0)
        {
            TransportTo(targetSceneName);
        }
    }
Пример #25
0
    public override void OnObjectStay(eObject obj)
    {
        base.OnObjectStay(obj);

        if (obj.GetState("player") > 0)
        {
            flag = true;
        }
    }
Пример #26
0
    public override void OnObjectEnter(eObject obj)
    {
        base.OnObjectEnter(obj);

        if (obj.GetState("player") > 0)
        {
            TriggerEvent(this, "light");
        }
    }
Пример #27
0
    public override void OnObjectExit(eObject obj)
    {
        base.OnObjectExit(obj);

        if (obj.GetState("player") > 0)
        {
            TriggerEvent(obj, "exitTalker");
        }
    }
Пример #28
0
    public override void OnObjectExit(eObject obj)
    {
        base.OnObjectExit(obj);

        if (obj.GetState("player") > 0)
        {
            TriggerEvent(m_bossObject, "playerExitPlatform " + m_platformNumber);
        }
    }
Пример #29
0
        public void drawImage(eObject obj)
        {
            int Left   = obj.x1 * Constant.cardWidth / 100;
            int Top    = obj.y1 * Constant.cardHeight / 100;
            int Width  = (obj.x2 - obj.x1) * Constant.cardWidth / 100;
            int Height = (obj.y2 - obj.y1) * Constant.cardHeight / 100;

            ppt.AddPic(Constant.ePath + obj.data, MsoTriState.msoFalse, MsoTriState.msoTrue, Left, Top, Width, Height);
            //ppt.AddPic("C:\\Program Files\\eFlash\\Data\\Media\\" + obj.data, MsoTriState.msoFalse, MsoTriState.msoTrue, Left, Top, Width, Height);
        }
Пример #30
0
        public void drawSound(eObject obj)
        {
            int Left   = obj.x1 * Constant.cardWidth / 100;
            int Top    = obj.y1 * Constant.cardHeight / 100;
            int Width  = (obj.x2 - obj.x1) * Constant.cardWidth / 100;
            int Height = (obj.y2 - obj.y1) * Constant.cardHeight / 100;

            ppt.AddSound(Constant.ePath + obj.data, Left, Top, Width, Height);
            //ppt.AddSound("C:\\Program Files\\eFlash\\Data\\Media\\" + obj.data, Left, Top, Width, Height);
        }
Пример #31
0
    public override void OnObjectEnter(eObject obj)
    {
        base.OnObjectEnter(obj);

        TriggerEvent(obj, "damageToEnemy " + 15.0f +
                     " " + Toolbox.ToRawString(transform.position));

        gameObject.SetActive(false);
        Destroy(gameObject, 0.1f);
    }
Пример #32
0
        public void drawImage(eObject obj)
        {
            int Left = obj.x1 * Constant.cardWidth / 100;
            int Top = obj.y1 * Constant.cardHeight / 100;
            int Width = (obj.x2 - obj.x1) * Constant.cardWidth / 100;
            int Height = (obj.y2 - obj.y1) * Constant.cardHeight / 100;

            ppt.AddPic(Constant.ePath + obj.data, MsoTriState.msoFalse, MsoTriState.msoTrue, Left, Top, Width, Height);
            //ppt.AddPic("C:\\Program Files\\eFlash\\Data\\Media\\" + obj.data, MsoTriState.msoFalse, MsoTriState.msoTrue, Left, Top, Width, Height);
        }
Пример #33
0
 public static void display(eObject obj, Panel panel)
 {
     switch (obj.type)
     {
         case Constant.textFile:
             initText(obj, panel);
             break;
         case Constant.imageFile:
             initImage(obj, panel);
             break;
         case Constant.soundFile:
             initSound(obj, panel);
             break;
         default:
             throw new ArgumentException("Invalid CreatorObject type: " + obj.type);
     }
 }
Пример #34
0
        public static void initSound(eObject obj, Panel panel)
        {
            int Left = obj.x1 * Constant.cardWidth / 100;
            int Top = obj.y1 * Constant.cardHeight / 100;
            int Width = (obj.x2 - obj.x1) * Constant.cardWidth / 100;
            int Height = (obj.y2 - obj.y1) * Constant.cardHeight / 100;

            string fileToPlay = obj.data;
            Player player = new Player();
            PlayButton newButton = new PlayButton(fileToPlay,player,fileToPlay);

            newButton.Text = "PLAY";
            newButton.Location = new System.Drawing.Point(Left, Top);
            newButton.Size = new System.Drawing.Size(Height, Width);
            panel.Controls.Add(newButton);
            newButton.Click += new EventHandler(newButton_Click);
        }
Пример #35
0
        public CreatorObject(LayoutEditor newCreator, eObject newObj)
        {
            if (newObj == null)
            {
                throw new ArgumentException("eObject argument to CreatorObject constructor cannot be null");
            }

            creator = newCreator;
            obj = newObj;

            InitializeComponent();

            switch (obj.type)
            {
                case Constant.textFile:
                    initTextBox();
                    break;
                case Constant.imageFile:
                    initImage();
                    break;
                case Constant.soundFile:
                    initAudio();
                    break;
                default:
                    throw new ArgumentException("Invalid CreatorObject type: " + obj.type);
            }

            bool canEdit = (creator.deck.type == Constant.noQuizDeck);
            deleteToolStripMenuItem.Enabled = canEdit;

            this.Leave += new System.EventHandler(this.ctlObject_Leave);
            this.Enter += new System.EventHandler(this.ctlObject_Enter);
            ctlObject.MouseDown += new MouseEventHandler(ctlObject_MouseDown);

            ctlObject.ContextMenuStrip = menuContext;

            if (obj.quizType == Constant.answerPrefix)
            {
                this.BackColor = Color.FromArgb(40, Color.Green);
            }
            else if (obj.quizType == Constant.questionPrefix)
            {
                this.BackColor = Color.FromArgb(40, Color.Red);
            }
        }
Пример #36
0
        /**
         * Retrieve all objects belonging to a card from the object table in the local database
         * Pre: local card id
         * Post: List of corresponding viewer objects (no binary data)
         */
        public static List<eObject> getViewerObjects(int cid)
        {
            List<eObject> eObjectList = new List<eObject>();
            string SQL;
            MySqlCommand cmd = new MySqlCommand();
            MySqlDataReader myData;

            connect();

            try
            {
                SQL = "SELECT cid,side,type,x1,x2,y1,y2,data FROM Objects WHERE cid = " + Convert.ToString(cid);

                cmd.Connection = conn;
                cmd.CommandText = SQL;

                myData = cmd.ExecuteReader();

                while (myData.Read())
                {
                    eObject obj = new eObject("viewer", myData.GetInt32(myData.GetOrdinal("cid")),
                                                                     myData.GetInt32(myData.GetOrdinal("side")),
                                                                     myData.GetString(myData.GetOrdinal("type")),
                                                                     myData.GetInt32(myData.GetOrdinal("x1")),
                                                                     myData.GetInt32(myData.GetOrdinal("x2")),
                                                                     myData.GetInt32(myData.GetOrdinal("y1")),
                                                                     myData.GetInt32(myData.GetOrdinal("y2")),
                                                                     myData.GetString(myData.GetOrdinal("data"))
                                                                );
                    eObjectList.Add(obj);
                }
                myData.Close();
                conn.Close();
                return eObjectList;
            }
            catch (MySql.Data.MySqlClient.MySqlException ex)
            {
                MessageBox.Show("Error " + ex.Number + " has occurred: " + ex.Message,
                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                conn.Close();
                throw new Exception();

            }
        }
Пример #37
0
 private void btnAudio_MouseDown(object sender, MouseEventArgs e)
 {
     eObject eObj = new eObject();
     eObj.type = Constant.soundFile;
     eObj.side = currentSideIndex;
     eObj.data = "[n]noFile.txt";
     CreatorObject draggingObj = new CreatorObject(this, eObj);
     btnTextbox.DoDragDrop(draggingObj, DragDropEffects.Move);
 }
Пример #38
0
 private void btnTextbox_MouseDown(object sender, MouseEventArgs e)
 {
     eObject eObj = new eObject();
     eObj.type = Constant.textFile;
     eObj.side = currentSideIndex;
     eObj.quizType = Constant.nonePrefix;
     eObj.actualFilename = "[n]noFile.txt";
     eObj.data = eObj.quizType + eObj.actualFilename;
     CreatorObject draggingObj = new CreatorObject(this, eObj);
     btnTextbox.DoDragDrop(draggingObj, DragDropEffects.Move);
 }
Пример #39
0
        /// <summary>
        /// Makes a deep copy of deck, duplicating all its cards,
        /// objects, and files, and sets it to be the current deck. 
        /// </summary>
        /// <param name="otherDeck">Deck to copy</param>
        /// <returns>Deck object of copy of deck</returns>
        private eFlash.Data.Deck deepCopy(eFlash.Data.Deck otherDeck)
        {
            otherDeck.load();

            _deck = new eFlash.Data.Deck(-1, otherDeck.type, otherDeck.category, otherDeck.subcategory, otherDeck.title, ProfileManager.getCurrentUserID(), ProfileManager.getCurrentNetID());

            // Put deck entry into DB
            saveDeck();

            Card newCard;
            eObject newObj;
            CreatorObject newCreatorObj;

            foreach (Card curCard in otherDeck.cardList)
            {
                newCard = new Card(curCard.tag, ProfileManager.getCurrentUserID());

                // Add each card to the DB
                newCard.cardID = dbAccess.insertLocalDB.insertToCards(newCard);
                dbAccess.insertLocalDB.insertToCDRelations(deck.id, newCard.cardID);

                foreach (eObject curObj in curCard.eObjectList)
                {
                    newObj = new eObject(newCard.cardID, curObj.side, curObj.type, curObj.x1, curObj.x2, curObj.y1, curObj.y2, curObj.data);

                    // Make a CreatorObject to let it load up the data file
                    newCreatorObj = CreatorObject.newFromEObject(this, newObj, 0);
                    newCreatorObj.initialize();
                    newObj.actualFilename = newObj.generateFileName();

                    // Save each object to DB and file
                    saveObject(newCreatorObj);
                }
            }

            return deck;
        }
Пример #40
0
        private void insertPictureOrSoundFile(string card_value, int cid, int side, string type, 
                                            int x1, int x2, int y1, int y2)
        {
            try
            {
                char[] param = new char[1];
                param[0] = '\\';
                string[] card_value_array = card_value.Split(param);
                string filename = card_value_array[card_value_array.Length - 1];
                byte[] _rawData;
                FileStream file;
                file = new FileStream(card_value, FileMode.Open, FileAccess.Read);
                _rawData = new byte[(int)file.Length];
                file.Read(_rawData, 0, (int)file.Length);
                file.Close();
                eObject curObj = new eObject(cid, side, type, x1, x2, y1, y2);
                curObj.efile = new eFile(_rawData);

                curObj.save();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #41
0
        private static void insertTextFile(string str, int cid, int side, string type, 
                                            int x1, int x2, int y1, int y2)
        {
            try
            {

                byte[] data = ConvertStringToByteArray(str);
                //For saving the eObject into FileSystem and DB,
                eObject curObj = new eObject(cid, side, type, x1, x2, y1, y2);
                curObj.efile = new eFile(data); //data is stream.toArry();
                curObj.save();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #42
0
        public static void initText(eObject obj, Panel panel)
        {
            int Left = obj.x1*Constant.cardWidth/100;
            int Top = obj.y1*Constant.cardHeight/100;
            int Width = (obj.x2-obj.x1)* Constant.cardWidth/100;
            int Height = (obj.y2-obj.y1)*Constant.cardHeight/100;

            string textToDisplay = obj.data;
            RichTextBox txtText=new RichTextBox();
            try
            {
                txtText.LoadFile(Constant.ePath + textToDisplay, RichTextBoxStreamType.RichText);
            }
            catch (Exception e)
            {
                MessageBox.Show("file not found");
            }
            txtText.Location = new System.Drawing.Point(Left, Top);
            txtText.ReadOnly = true;
            txtText.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.None;
            txtText.Size = new System.Drawing.Size(Width, Height);
            txtText.TabStop = false;
            txtText.BorderStyle = System.Windows.Forms.BorderStyle.None;
            txtText.BackColor = System.Drawing.Color.White;
            txtText.DetectUrls = false;

            panel.Controls.Add(txtText);
        }
Пример #43
0
        public static int parseBLOB(byte[] blob, int uid)
        {
            int size = 0;
            int curDid = -1;
            int curCid = -1;
            byte[] data = null;
            Deck deck = null;
            eObject curObj = null;
            Card curCard = null;
            MemoryStream stream = new MemoryStream(blob);
            XmlTextReader reader = new XmlTextReader(stream);

                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                        case XmlNodeType.Element:

                            if (reader.Name == "Deck")
                            {
                                deck = new Deck(reader.GetAttribute("cat"), reader.GetAttribute("subcat"),
                                    reader.GetAttribute("title"), reader.GetAttribute("type"),Convert.ToInt32(reader.GetAttribute("nuid")), uid);

                                try
                                {
                                    //Insert to Decks table in local database
                                    curDid = deck.saveToDB();
                                }
                                catch
                                {
                                    throw new Exception("Error Writting Deck!!!");
                                }
                            }
                            else if (reader.Name == "Card")
                            {
                                curCard = new Card(reader.GetAttribute("tag"), uid);

                                try
                                {
                                     //Insert to Cards table in local database
                                    curCid = curCard.saveToDB(curDid);
                                }
                                catch
                                {
                                    throw new Exception("Error Writting Card!!!");
                                }

                            }
                            else if (reader.Name == "Object")
                            {
                                //First create the array of bytes for the blob
                                size = Convert.ToInt32(reader.GetAttribute("size"));
                                data = new byte[size];

                                curObj = new eObject( curCid,
                                                                         Convert.ToInt32(reader.GetAttribute("side")),
                                                                         reader.GetAttribute("type"),
                                                                         Convert.ToInt32(reader.GetAttribute("x1")),
                                                                         Convert.ToInt32(reader.GetAttribute("x2")),
                                                                         Convert.ToInt32(reader.GetAttribute("y1")),
                                                                         Convert.ToInt32(reader.GetAttribute("y2"))
                                                                         );

                                try
                                {
                                    string qType = reader.GetAttribute("quizType");
                                    if (qType == Constant.nonePrefix || qType == Constant.answerPrefix || qType == Constant.questionPrefix)
                                    {
                                        curObj.quizType = qType;
                                    }
                                }
                                catch {}

                                 try
                                {
                                    reader.ReadElementContentAsBase64(data, 0, size);
                                    curObj.efile = new eFile(data);

                                    //save to file and update DB
                                    curObj.save();
                                 }
                                catch
                                 {
                                    throw new Exception("Error Saving Object !!!");
                                 }

                            }

                            break;
                    }

                }
                return curDid;
        }
Пример #44
0
 public static void insertToObjects(eObject obj)
 {
     insertToObjects(obj.cid, obj.side, obj.type, obj.x1, obj.x2, obj.y1, obj.y2, obj.data);
 }
Пример #45
0
        public void drawText(eObject obj)
        {
            int Left = obj.x1 * Constant.cardWidth / 100;
            int Top = obj.y1 * Constant.cardHeight / 100;
            int Width = (obj.x2 - obj.x1) * Constant.cardWidth / 100;
            int Height = (obj.y2 - obj.y1) * Constant.cardHeight / 100;

            RichTextBox txtText = new RichTextBox();
            try
            {
                txtText.LoadFile(Constant.ePath + obj.data, RichTextBoxStreamType.RichText);
                //txtText.LoadFile("C:\\Program Files\\eFlash\\Data\\Media\\" + obj.data, RichTextBoxStreamType.RichText);
            }
            catch (Exception e)
            {
                MessageBox.Show("file not found");
            }

            MsoTriState isItalic = MsoTriState.msoFalse;
            MsoTriState isBold = MsoTriState.msoFalse;
            MsoTriState isUnderlined = MsoTriState.msoFalse;
            if (txtText.Font.Italic)
                isItalic = MsoTriState.msoTrue;
            if (txtText.Font.Bold)
                isBold = MsoTriState.msoTrue;
            if (txtText.Font.Underline)
                isUnderlined = MsoTriState.msoTrue;
            //byte r = txtText.ForeColor.R;
            //byte g = txtText.ForeColor.G;
            //byte b = txtText.ForeColor.B;
            //int col = 256 * 256 * r + 256 * g + b;

            ppt.AddText(txtText.Text, txtText.Font.Style.ToString(), txtText.Font.Size * PPTFONTMULTIPLIER, isBold, isItalic, isUnderlined, Left, Top, Width, Height);
        }
Пример #46
0
        public void drawSound(eObject obj)
        {
            int Left = obj.x1 * Constant.cardWidth / 100;
            int Top = obj.y1 * Constant.cardHeight / 100;
            int Width = (obj.x2 - obj.x1) * Constant.cardWidth / 100;
            int Height = (obj.y2 - obj.y1) * Constant.cardHeight / 100;

            ppt.AddSound(Constant.ePath + obj.data, Left, Top, Width, Height);
            //ppt.AddSound("C:\\Program Files\\eFlash\\Data\\Media\\" + obj.data, Left, Top, Width, Height);
        }
Пример #47
0
        /// <summary>
        /// Applies a template into this flashcard
        /// </summary>
        /// <param name="template">Template to use</param>
        public void loadTemplate(Template template)
        {
            Card card = new Card("", ProfileManager.getCurrentUserID());

            if (currentCard.cardID == -1)
            {
                card.cardID = NEW_TEMPLATE_CARD;
            }
            else
            {
                card.cardID = currentCard.cardID;
            }

            eObject curEObj;
            TemplateObject curObj;
            // Fill the sides with objects
            for (int i = 0; i < template.objects.Count; i++)
            {
                curObj = template.objects[i];
                curEObj = new eObject(-1, curObj.side, curObj.type, curObj.x1, curObj.x2, curObj.y1, curObj.y2, curObj.quizType + "noFile.txt");
                card.eObjectList.Add(curEObj);
            }

            if (deck.cardList.Count == 0)
            {
                deck.cardList.Add(card);
                setFlashcard(card, 0);
            }
            else if (currentCard.index == -1)
            {
                deck.cardList.Add(card);
                setFlashcard(card, deck.cardList.Count - 1);
            }
            else
            {
                //deck.cardList[currentCard.index] = card;
                setFlashcard(card, currentCard.index);
            }

            templateChanged = true;
            changed = false;
            promptAtTemplateChange = false;
        }
Пример #48
0
 public void addObject(eObject obj)
 {
     _eObjectList.Add(obj);
 }
Пример #49
0
        public static CreatorObject newFromEObject(LayoutEditor newCreator, eObject newObj, int tabStop)
        {
            CreatorObject curNewObj = new CreatorObject(newCreator, newObj);

            curNewObj.Name = "creatorObject";
            curNewObj.TabIndex = tabStop;
            curNewObj.TabStop = true;

            curNewObj.initialize();

            curNewObj.setCoords(newObj.x1, newObj.y1, newObj.x2, newObj.y2);

            return curNewObj;
        }
Пример #50
0
        public eObject toEObject()
        {
            obj.x1 = Convert.ToInt32(coords[COORDS_ULX] * 100.0 / LayoutEditor.CANVAS_WIDTH);
            obj.y1 = Convert.ToInt32(coords[COORDS_ULY] * 100.0 / LayoutEditor.CANVAS_HEIGHT);
            obj.x2 = Convert.ToInt32(coords[COORDS_BRX] * 100.0 / LayoutEditor.CANVAS_WIDTH);
            obj.y2 = Convert.ToInt32(coords[COORDS_BRY] * 100.0 / LayoutEditor.CANVAS_HEIGHT);

            string fileName = obj.generateFileName();

            obj = new eObject(cid, side, type, obj.x1, obj.x2, obj.y1, obj.y2, fileName);
            return obj;
        }